aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/kstd/kstd/ring_buffer.tests.cpp82
1 files changed, 82 insertions, 0 deletions
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 <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_exception.hpp>
+#include <cstddef>
+#include <type_traits>
+#include <utility>
+
+SCENARIO("Ring Buffer interface types", "[kstd][ring_buffer]")
+{
+ GIVEN("A ring buffer of float")
+ {
+ using buffer = kstd::ring_buffer<float, 100>;
+
+ THEN("value_type is 'float'")
+ {
+ STATIC_REQUIRE(std::is_same_v<float, buffer::value_type>);
+ }
+
+ THEN("reference is 'float &'")
+ {
+ STATIC_REQUIRE(std::is_same_v<float &, buffer::reference>);
+ }
+
+ THEN("const_reference is 'float const &'")
+ {
+ STATIC_REQUIRE(std::is_same_v<float const &, buffer::const_reference>);
+ }
+
+ THEN("pointer is 'float *'")
+ {
+ STATIC_REQUIRE(std::is_same_v<float *, buffer::pointer>);
+ }
+
+ THEN("size_type is 'std::size_t'")
+ {
+ STATIC_REQUIRE(std::is_same_v<std::size_t, buffer::size_type>);
+ }
+
+ THEN("const_pointer is 'float const *'")
+ {
+ STATIC_REQUIRE(std::is_same_v<float const *, buffer::const_pointer>);
+ }
+
+ THEN("the return type of at() is 'reference' on a non-const buffer")
+ {
+ STATIC_REQUIRE(std::is_same_v<buffer::reference, decltype(std::declval<buffer &>().at(0))>);
+ }
+
+ THEN("the return type of at() is 'const_reference' on a non-const buffer")
+ {
+ STATIC_REQUIRE(std::is_same_v<buffer::const_reference, decltype(std::declval<buffer const &>().at(0))>);
+ }
+
+ THEN("the return type of operator[] is 'reference' on a non-const buffer")
+ {
+ STATIC_REQUIRE(std::is_same_v<buffer::reference, decltype(std::declval<buffer &>()[0])>);
+ }
+
+ THEN("the return type of operator[] is 'const_reference' on a non-const buffer")
+ {
+ STATIC_REQUIRE(std::is_same_v<buffer::const_reference, decltype(std::declval<buffer const &>()[0])>);
+ }
+
+ THEN("the return type of capacity() is `size_type`")
+ {
+ STATIC_REQUIRE(std::is_same_v<buffer::size_type, decltype(std::declval<buffer &>().capacity())>);
+ }
+
+ THEN("the return type of empty() is `bool`")
+ {
+ STATIC_REQUIRE(std::is_same_v<bool, decltype(std::declval<buffer &>().empty())>);
+ }
+
+ THEN("the return type of size() is `size_type`")
+ {
+ STATIC_REQUIRE(std::is_same_v<buffer::size_type, decltype(std::declval<buffer &>().size())>);
+ }
+
+ THEN("the return type of max_size() is `size_type`")
+ {
+ STATIC_REQUIRE(std::is_same_v<buffer::size_type, decltype(std::declval<buffer &>().max_size())>);
+ }
+ }
+}
+
SCENARIO("Ring Buffer initialization and construction", "[ring_buffer]")
{
GIVEN("An empty context")