Update tests

This commit is contained in:
Georg Hagen
2025-04-30 21:26:31 +02:00
parent b6eacc8338
commit 8fe180bad2
2 changed files with 117 additions and 106 deletions

View File

@@ -477,6 +477,7 @@ namespace OpenVulkano
else else
return (Parent::head = (Parent::HeadId() + 1) % Capacity()); return (Parent::head = (Parent::HeadId() + 1) % Capacity());
} }
public: public:
~RingBuffer() { Parent::Clear(); } ~RingBuffer() { Parent::Clear(); }

View File

@@ -109,10 +109,20 @@ TEST_CASE("Index-based Access and Wraparound", "[RingBuffer]") {
REQUIRE(buf[1] == 2); REQUIRE(buf[1] == 2);
REQUIRE(buf[2] == 3); REQUIRE(buf[2] == 3);
buf.PopBack(); // Remove 1 buf.PopBack();
buf.Push(4); // Overwrites oldest (2) buf.Push(4);
REQUIRE(buf[0] == 2); // Wrap-around behavior depends on ring position REQUIRE(buf[0] == 2);
REQUIRE(buf[1] == 3);
REQUIRE(buf[2] == 4);
// Test full wraparound
buf.Push(5);
buf.Push(6);
REQUIRE(buf[0] == 4);
REQUIRE(buf[1] == 5);
REQUIRE(buf[2] == 6);
} }
TEST_CASE("Emplace and EmplaceBack/Front work correctly", "[RingBuffer]") { TEST_CASE("Emplace and EmplaceBack/Front work correctly", "[RingBuffer]") {