aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-10-01 21:54:59 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-10-01 21:54:59 +0200
commit3c6253cbd2ef9342ff572c9a09cc612f54f1fab6 (patch)
tree350dda803f436ac5332d15a0467a881515ca7f3b
parent3385a54840c7985dde6a5b47d263920db4d6ed06 (diff)
downloadkernel-3c6253cbd2ef9342ff572c9a09cc612f54f1fab6.tar.xz
kernel-3c6253cbd2ef9342ff572c9a09cc612f54f1fab6.zip
kstd: ring_buffer: move construction tests
-rw-r--r--libs/kstd/kstd/ring_buffer.tests.cpp64
1 files 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<int, 5>{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<int, 5>{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<int, 5>{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<int, 5>{3};
+ auto buffer = kstd::ring_buffer<int, 5>{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<int, 5>{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());
}
}
}