From 3a0f05541cc619128ee35a75921d7a53e01755ca Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 30 Sep 2026 18:03:17 +0200 Subject: kstd: ring_buffer: add interface type tests --- libs/kstd/kstd/ring_buffer.tests.cpp | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/libs/kstd/kstd/ring_buffer.tests.cpp b/libs/kstd/kstd/ring_buffer.tests.cpp index bf1ae2a0..f0be78a1 100644 --- a/libs/kstd/kstd/ring_buffer.tests.cpp +++ b/libs/kstd/kstd/ring_buffer.tests.cpp @@ -6,6 +6,88 @@ #include #include +#include +#include +#include + +SCENARIO("Ring Buffer interface types", "[kstd][ring_buffer]") +{ + GIVEN("A ring buffer of float") + { + using buffer = kstd::ring_buffer; + + THEN("value_type is 'float'") + { + STATIC_REQUIRE(std::is_same_v); + } + + THEN("reference is 'float &'") + { + STATIC_REQUIRE(std::is_same_v); + } + + THEN("const_reference is 'float const &'") + { + STATIC_REQUIRE(std::is_same_v); + } + + THEN("pointer is 'float *'") + { + STATIC_REQUIRE(std::is_same_v); + } + + THEN("size_type is 'std::size_t'") + { + STATIC_REQUIRE(std::is_same_v); + } + + THEN("const_pointer is 'float const *'") + { + STATIC_REQUIRE(std::is_same_v); + } + + THEN("the return type of at() is 'reference' on a non-const buffer") + { + STATIC_REQUIRE(std::is_same_v().at(0))>); + } + + THEN("the return type of at() is 'const_reference' on a non-const buffer") + { + STATIC_REQUIRE(std::is_same_v().at(0))>); + } + + THEN("the return type of operator[] is 'reference' on a non-const buffer") + { + STATIC_REQUIRE(std::is_same_v()[0])>); + } + + THEN("the return type of operator[] is 'const_reference' on a non-const buffer") + { + STATIC_REQUIRE(std::is_same_v()[0])>); + } + + THEN("the return type of capacity() is `size_type`") + { + STATIC_REQUIRE(std::is_same_v().capacity())>); + } + + THEN("the return type of empty() is `bool`") + { + STATIC_REQUIRE(std::is_same_v().empty())>); + } + + THEN("the return type of size() is `size_type`") + { + STATIC_REQUIRE(std::is_same_v().size())>); + } + + THEN("the return type of max_size() is `size_type`") + { + STATIC_REQUIRE(std::is_same_v().max_size())>); + } + } +} + SCENARIO("Ring Buffer initialization and construction", "[ring_buffer]") { GIVEN("An empty context") -- cgit v1.2.3