diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-10-01 18:50:26 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-10-01 18:50:26 +0200 |
| commit | 390e34ce7fc09daddd8180c4e687ab585e102c47 (patch) | |
| tree | e5dd4b827aee630245649c0e30b5ab208db70f55 | |
| parent | 6ba358c98c855b685077a21160b357663be99b32 (diff) | |
| download | kernel-390e34ce7fc09daddd8180c4e687ab585e102c47.tar.xz kernel-390e34ce7fc09daddd8180c4e687ab585e102c47.zip | |
kstd: ring_buffer: add more range-based tests
| -rw-r--r-- | libs/kstd/kstd/ring_buffer.tests.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libs/kstd/kstd/ring_buffer.tests.cpp b/libs/kstd/kstd/ring_buffer.tests.cpp index 7a9c56be..a118c2c3 100644 --- a/libs/kstd/kstd/ring_buffer.tests.cpp +++ b/libs/kstd/kstd/ring_buffer.tests.cpp @@ -383,6 +383,21 @@ SCENARIO("Ring Buffer iterators", "[kstd][ring_buffer]") REQUIRE(buffer.cbegin() == buffer.cend()); } + THEN("the distance between begin() and end() is 0") + { + REQUIRE(std::ranges::distance(buffer.begin(), buffer.end()) == 0); + } + + THEN("the distance between cbegin() and cend() is 0") + { + REQUIRE(std::ranges::distance(buffer.cbegin(), buffer.cend()) == 0); + } + + THEN("the distance on the entire buffer is 0") + { + REQUIRE(std::ranges::distance(buffer) == 0); + } + WHEN("working through a const reference") { auto const & ref = buffer; @@ -396,6 +411,16 @@ SCENARIO("Ring Buffer iterators", "[kstd][ring_buffer]") { REQUIRE(buffer.begin() == buffer.end()); } + + THEN("the distance between begin() and end() is 0") + { + REQUIRE(std::ranges::distance(buffer.begin(), buffer.end()) == 0); + } + + THEN("the distance on the entire buffer is 0") + { + REQUIRE(std::ranges::distance(buffer) == 0); + } } } @@ -418,6 +443,21 @@ SCENARIO("Ring Buffer iterators", "[kstd][ring_buffer]") REQUIRE(buffer.begin() != buffer.cend()); } + THEN("the distance between begin() and end() is 3") + { + REQUIRE(std::ranges::distance(buffer.begin(), buffer.end()) == 3); + } + + THEN("the distance between cbegin() and cend() is 3") + { + REQUIRE(std::ranges::distance(buffer.cbegin(), buffer.cend()) == 3); + } + + THEN("the distance on the entire buffer is 3") + { + REQUIRE(std::ranges::distance(buffer) == 3); + } + THEN("begin() returns an iterator to the first element") { REQUIRE(*buffer.begin() == 'a'); @@ -519,6 +559,16 @@ SCENARIO("Ring Buffer iterators", "[kstd][ring_buffer]") REQUIRE(ref.begin() != ref.end()); } + THEN("the distance between begin() and end() is 3") + { + REQUIRE(std::ranges::distance(buffer.begin(), buffer.end()) == 3); + } + + THEN("the distance on the entire buffer is 3") + { + REQUIRE(std::ranges::distance(buffer) == 3); + } + THEN("begin() returns an iterator to the first element") { REQUIRE(*ref.begin() == 'a'); |
