3#include "../../catch2/catch.hpp"
8#define MX_NO_ERROR_REPORTS
10#include "../../../include/sigproc/circularBuffer.hpp"
18SCENARIO(
"creating a circular buffer with branching",
"[sigproc::circularBuffer::circularBufferBranch]" )
20 GIVEN(
"a circular buffer" )
22 WHEN(
"adding exactly max entries worth" )
32 REQUIRE( cb[0] == 0 );
33 REQUIRE( cb[1] == 1 );
34 REQUIRE( cb[2] == 2 );
35 REQUIRE( cb[3] == 3 );
36 REQUIRE( cb[4] == 4 );
39 REQUIRE( cb[-1] == 4 );
40 REQUIRE( cb[-2] == 3 );
41 REQUIRE( cb[-3] == 2 );
42 REQUIRE( cb[-4] == 1 );
45 REQUIRE( cb.
at(cb.
latest(),0) == 4 );
48 WHEN(
"adding new values past the end" )
60 REQUIRE( cb[0] == 2 );
61 REQUIRE( cb[1] == 3 );
62 REQUIRE( cb[2] == 4 );
63 REQUIRE( cb[3] == 5 );
64 REQUIRE( cb[4] == 6 );
67 REQUIRE( cb[-1] == 6 );
68 REQUIRE( cb[-2] == 5 );
69 REQUIRE( cb[-3] == 4 );
70 REQUIRE( cb[-4] == 3 );
73 REQUIRE( cb.
at(cb.
latest(),0) == 6 );
76 WHEN(
"wrapping when not full" )
85 REQUIRE( cb[0] == 0 );
86 REQUIRE( cb[1] == 1 );
87 REQUIRE( cb[2] == 2 );
88 REQUIRE( cb[3] == 3 );
89 REQUIRE( cb[4] == 0 );
92 REQUIRE( cb[-1] == 3 );
93 REQUIRE( cb[-2] == 2 );
94 REQUIRE( cb[-3] == 1 );
95 REQUIRE( cb[-4] == 0 );
106SCENARIO(
"creating a circular buffer with indexing",
"[sigproc::circularBuffer::circularBufferIndex]" )
108 GIVEN(
"a circular buffer" )
110 WHEN(
"adding exactly max entries worth" )
120 REQUIRE( cb[0] == 0 );
121 REQUIRE( cb[1] == 1 );
122 REQUIRE( cb[2] == 2 );
123 REQUIRE( cb[3] == 3 );
124 REQUIRE( cb[4] == 4 );
127 REQUIRE( cb[-1] == 4 );
128 REQUIRE( cb[-2] == 3 );
129 REQUIRE( cb[-3] == 2 );
130 REQUIRE( cb[-4] == 1 );
133 REQUIRE( cb.
at(cb.
latest(),0) == 4 );
136 WHEN(
"adding new values past the end" )
148 REQUIRE( cb[0] == 2 );
149 REQUIRE( cb[1] == 3 );
150 REQUIRE( cb[2] == 4 );
151 REQUIRE( cb[3] == 5 );
152 REQUIRE( cb[4] == 6 );
155 REQUIRE( cb[-1] == 6 );
156 REQUIRE( cb[-2] == 5 );
157 REQUIRE( cb[-3] == 4 );
158 REQUIRE( cb[-4] == 3 );
161 REQUIRE( cb.
at(cb.
latest(),0) == 6 );
SCENARIO("Loading aoAtmosphere config settings", "[ao::analysis::aoAtmosphere]")
void maxEntries(indexT maxEnt)
Set the maximum size of the buffer.
indexT earliest()
Returns the index of the earliest entry.
indexT latest()
Returns the index of the latest entry.
void nextEntry(const storedT &newEnt)
Add the next entry to the circular buffer.
Circular buffer which wraps with an if statement (branching) [faster than mod, less memory than index...
storedT & at(indexT refEntry, indexT idx)
Interface implementation for entry access.
Circular buffer which wraps with a pre-populated indices array [generally fastest].
storedT & at(indexT refEntry, indexT idx)
Interface implementation for entry access.