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.isEmpty());
10 CHECK(!buf.isFull());
11 CHECK(buf.size() == 0);
12
13 buf.addBack(15);
14 CHECK(!buf.isEmpty());
15 CHECK(!buf.isFull());
16 CHECK(buf.size() == 1);
17 CHECK(buf[0] == 15);
18
19 buf[0] = 25;
20 CHECK(buf[0] == 25);
21
22 buf.addFront(17);
23 CHECK(!buf.isEmpty());
24 CHECK(buf.isFull());
25 CHECK(buf.size() == 2);
26 CHECK(buf[0] == 17);
27 CHECK(buf[1] == 25);
28
29 buf[1] = 35;
30 CHECK(buf[0] == 17);
31 CHECK(buf[1] == 35);
32 buf[0] = 27;
33 CHECK(buf[0] == 27);
34 CHECK(buf[1] == 35);
35
36 int a = buf.removeBack();
37 CHECK(a == 35);
38 CHECK(buf.size() == 1);
39 CHECK(buf[0] == 27);
40
41 int b = buf.removeFront();
42 CHECK(b == 27);
43 CHECK(buf.isEmpty());
44}
TEST_CASE("CircularBuffer")
constexpr void addBack(const T &element)
constexpr bool isFull() const
constexpr T & removeFront()
constexpr T & removeBack()
constexpr size_t size() const
constexpr bool isEmpty() const
constexpr void addFront(const T &element)
CHECK(m3==m3)
This file implemented 3 utility functions:
Definition Autofire.cc:11