-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_read_char.cpp
35 lines (28 loc) · 1.01 KB
/
test_read_char.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <RingBuffer.h>
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Data is removed from the ring buffer via 'read_char'", "[Ringbuffer-read_char-01]")
{
arduino::RingBufferN<2> ringbuffer;
WHEN("The ringbuffer is empty")
THEN("'read_char' should return -1")
REQUIRE(ringbuffer.read_char() == -1);
WHEN("The ringbuffer contains data")
{
ringbuffer.store_char('A');
ringbuffer.store_char('B');
THEN("'read_char' should return first inserted element first (FIFO)")
{
REQUIRE(ringbuffer.read_char() == 'A');
REQUIRE(ringbuffer.read_char() == 'B');
}
}
}