summaryrefslogtreecommitdiff
path: root/modules/core/tests
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-03 16:20:39 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-03 16:20:39 +0200
commit738bc442f680bda95667e4fd1ae743c6f6afeab0 (patch)
treec518bb64f401501f11e45e1ec9536e1dee2d5187 /modules/core/tests
parent95145a733d15bef84aa294f31d5cf8cefc66a1e0 (diff)
Made transport slicing possible
Diffstat (limited to 'modules/core/tests')
-rw-r--r--modules/core/tests/ring_buffer.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/core/tests/ring_buffer.cpp b/modules/core/tests/ring_buffer.cpp
new file mode 100644
index 0000000..0217b4f
--- /dev/null
+++ b/modules/core/tests/ring_buffer.cpp
@@ -0,0 +1,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");
+}
+
+}