-
Notifications
You must be signed in to change notification settings - Fork 0
/
RingBuffer_test.cpp
60 lines (45 loc) · 1.13 KB
/
RingBuffer_test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* RingBuffer_test.cpp
*
* Created on: Sep 22, 2015
* Author: peter
*/
#include <boost/test/unit_test.hpp>
#include "RingBuffer.h"
namespace hdlc {
BOOST_AUTO_TEST_CASE( test_RingBuffer_isEmpty ) {
RingBuffer<16> ringBuffer;
BOOST_CHECK(ringBuffer.isEmpty());
ringBuffer.put(0);
BOOST_CHECK(!ringBuffer.isEmpty());
ringBuffer.get();
BOOST_CHECK(ringBuffer.isEmpty());
}
BOOST_AUTO_TEST_CASE( test_RingBuffer_isFull ) {
RingBuffer<16> ringBuffer;
for(int i = 0; i < 15; i++) {
ringBuffer.put(i);
}
BOOST_CHECK(!ringBuffer.isFull());
ringBuffer.put(15);
BOOST_CHECK(ringBuffer.isFull());
ringBuffer.get();
BOOST_CHECK(!ringBuffer.isFull());
}
BOOST_AUTO_TEST_CASE( test_RingBuffer_put_get ) {
RingBuffer<16> ringBuffer;
ringBuffer.put(42);
BOOST_CHECK(42 == ringBuffer.get());
}
BOOST_AUTO_TEST_CASE( test_RingBuffer_peek ) {
RingBuffer<16> ringBuffer;
ringBuffer.put(42);
BOOST_CHECK(42 == ringBuffer.peek(0));
}
BOOST_AUTO_TEST_CASE( test_RingBuffer_size ) {
RingBuffer<16> ringBuffer;
BOOST_CHECK(0 == ringBuffer.size());
ringBuffer.put(42);
BOOST_CHECK(1 == ringBuffer.size());
}
} /* namespace hdlc */