summaryrefslogtreecommitdiff
path: root/modules/core/tests/ring_buffer.cpp
blob: 0217b4ff1d6447a0e172e98875820a4c83ced94d (plain)
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
#include "../c++/test/suite.hpp"
#include "../c++/buffer.hpp"

namespace {
SAW_TEST("Ring Buffer Write Advance") {
		using namespace saw;

		uint64_t size = 1024u;
		ring_buffer buff{};

		uint64_t advance = 32u;
		buff.write_advance(advance);

		SAW_EXPECT(buff.read_position() == 0u, "Unexpected read position");
		SAW_EXPECT(buff.write_position() == 32u, "Unexpected write position");
		SAW_EXPECT(buff.read_composite_length() == 32u, "Unexpected write position");
}

SAW_TEST("Ring Buffer on Heap Write Advance") {
		using namespace saw;

		uint64_t size = 1024u;
		own<buffer> r_buff = heap<ring_buffer>();
		buffer& buff = *r_buff;

		uint64_t advance = 32u;
		buff.write_advance(advance);

		SAW_EXPECT(buff.read_position() == 0u, "Unexpected read position");
		SAW_EXPECT(buff.write_position() == 32u, "Unexpected write position");
		SAW_EXPECT(buff.read_composite_length() == 32u, "Unexpected write position");
}

}