From 3c6253cbd2ef9342ff572c9a09cc612f54f1fab6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 1 Oct 2026 21:54:59 +0200 Subject: kstd: ring_buffer: move construction tests --- libs/kstd/kstd/ring_buffer.tests.cpp | 64 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/libs/kstd/kstd/ring_buffer.tests.cpp b/libs/kstd/kstd/ring_buffer.tests.cpp index f6613f33..32002d79 100644 --- a/libs/kstd/kstd/ring_buffer.tests.cpp +++ b/libs/kstd/kstd/ring_buffer.tests.cpp @@ -232,31 +232,46 @@ SCENARIO("Ring Buffer initialization and construction", "[kstd][ring_buffer]") "[KSTD] Tried to construct a ring buffer with more elements than it can support.")); } } - } - GIVEN("A full buffer") - { - auto buffer = kstd::ring_buffer{5}; - - THEN("the capacity is 5") + WHEN("constructing by n-value-initialized constructor using a capacity of 5") { - REQUIRE(buffer.capacity() == 5); - } + auto buffer = kstd::ring_buffer{3}; - THEN("the buffer is not empty") - { - REQUIRE_FALSE(buffer.empty()); + THEN("the capacity is 5") + { + REQUIRE(buffer.capacity() == 5); + } + + THEN("the buffer is not empty") + { + REQUIRE_FALSE(buffer.empty()); + } + + THEN("the size is equal to the number of copies") + { + REQUIRE(buffer.size() == 3); + } + + THEN("the maximum size is equal to the capacity") + { + REQUIRE(buffer.max_size() == buffer.capacity()); + } } - THEN("the size is equal to the capacity") + WHEN("constructing by n-value-initialized constructor using a capacity of 5 and 6 copies") { - REQUIRE(buffer.size() == buffer.capacity()); + THEN("the constructor panics") + { + REQUIRE_THROWS_MATCHES((kstd::ring_buffer{6}), kstd::tests::os_panic, + Catch::Matchers::Message( + "[KSTD] Tried to construct a ring buffer with more elements than it can support.")); + } } } - WHEN("constructing by n-value-initialized constructor using a capacity of 5") + GIVEN("A full buffer") { - auto buffer = kstd::ring_buffer{3}; + auto buffer = kstd::ring_buffer{5}; THEN("the capacity is 5") { @@ -268,24 +283,9 @@ SCENARIO("Ring Buffer initialization and construction", "[kstd][ring_buffer]") REQUIRE_FALSE(buffer.empty()); } - THEN("the size is equal to the number of copies") - { - REQUIRE(buffer.size() == 3); - } - - THEN("the maximum size is equal to the capacity") - { - REQUIRE(buffer.max_size() == buffer.capacity()); - } - } - - WHEN("constructing by n-value-initialized constructor using a capacity of 5 and 6 copies") - { - THEN("the constructor panics") + THEN("the size is equal to the capacity") { - REQUIRE_THROWS_MATCHES( - (kstd::ring_buffer{6}), kstd::tests::os_panic, - Catch::Matchers::Message("[KSTD] Tried to construct a ring buffer with more elements than it can support.")); + REQUIRE(buffer.size() == buffer.capacity()); } } } -- cgit v1.2.3