-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_clear.cpp
32 lines (26 loc) · 1 KB
/
test_clear.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
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <RingBuffer.h>
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Calling 'clear' on a empty ring buffer should have no effect", "[Ringbuffer-clear-01]")
{
arduino::RingBufferN<2> ringbuffer;
REQUIRE(ringbuffer.available() == 0);
ringbuffer.clear();
REQUIRE(ringbuffer.available() == 0);
}
TEST_CASE ("Calling 'clear' on a partially filled ring buffer should \"remove\" all elements", "[Ringbuffer-clear-02]")
{
arduino::RingBufferN<2> ringbuffer;
ringbuffer.store_char('A');
REQUIRE(ringbuffer.available() == 1);
ringbuffer.clear();
REQUIRE(ringbuffer.available() == 0);
}