-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_availableForStore.cpp
30 lines (24 loc) · 1 KB
/
test_availableForStore.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
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <RingBuffer.h>
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("'availableForStore' should return ring buffer size for empty ring buffer", "[Ringbuffer-availableForStore-01]")
{
arduino::RingBufferN<2> ringbuffer;
REQUIRE(ringbuffer.availableForStore() == 2);
}
TEST_CASE ("'availableForStore' should return number of free elements in ringbuffer", "[Ringbuffer-availableForStore-02]")
{
arduino::RingBufferN<2> ringbuffer;
ringbuffer.store_char('A');
REQUIRE(ringbuffer.availableForStore() == 1);
ringbuffer.store_char('B');
REQUIRE(ringbuffer.availableForStore() == 0);
}