openMSX
CircularBuffer_test.cc
Go to the documentation of this file.
1#include "catch.hpp"
2#include "CircularBuffer.hh"
3
4using namespace openmsx;
5
6TEST_CASE("CircularBuffer")
7{
9 CHECK(buf.empty());
10 CHECK(!buf.full());
11 CHECK(buf.size() == 0);
12
13 buf.push_back(15);
14 CHECK(!buf.empty());
15 CHECK(!buf.full());
16 CHECK(buf.size() == 1);
17 CHECK(buf[0] == 15);
18 CHECK(buf.front() == 15);
19 CHECK(buf.back() == 15);
20
21 buf[0] = 25;
22 CHECK(buf[0] == 25);
23
24 buf.push_front(17);
25 CHECK(!buf.empty());
26 CHECK(!buf.full());
27 CHECK(buf.size() == 2);
28 CHECK(buf[0] == 17);
29 CHECK(buf[1] == 25);
30 CHECK(buf.front() == 17);
31 CHECK(buf.back() == 25);
32
33 buf[1] = 35;
34 CHECK(buf[0] == 17);
35 CHECK(buf[1] == 35);
36 buf[0] = 27;
37 CHECK(buf[0] == 27);
38 CHECK(buf[1] == 35);
39
40 buf.push_back(11);
41 CHECK(buf.full());
42 CHECK(!buf.empty());
43 CHECK(buf.size() == 3);
44 CHECK(buf.front() == 27);
45 CHECK(buf.back() == 11);
46
47 CHECK(buf.pop_front() == 27);
48 CHECK(!buf.full());
49 CHECK(buf.size() == 2);
50 CHECK(buf.front() == 35);
51 CHECK(buf.back() == 11);
52
53 CHECK(buf.pop_back() == 11);
54 CHECK(buf.size() == 1);
55 CHECK(buf[0] == 35);
56
57 CHECK(buf.pop_front() == 35);
58 CHECK(buf.empty());
59}
TEST_CASE("CircularBuffer")
constexpr bool full() const
constexpr bool empty() const
constexpr void push_front(const T &element)
constexpr size_t size() const
constexpr T & pop_front()
constexpr void push_back(const T &element)
CHECK(m3==m3)
This file implemented 3 utility functions:
Definition Autofire.cc:11