-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathtest_availableForStore.cpp
32 lines (26 loc) · 1.05 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
31
32
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <api/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);
}