aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd/tests/include
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-05-01 13:11:37 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-05-01 13:11:37 +0200
commit338d9b2b6fc517df2135089699234232495324d6 (patch)
treeb1c8c7d35baca475409f80d5e9d5d1691c7151ae /libs/kstd/tests/include
parent52b2fd214c8484a55c409c72c90929428e261949 (diff)
downloadkernel-338d9b2b6fc517df2135089699234232495324d6.tar.xz
kernel-338d9b2b6fc517df2135089699234232495324d6.zip
kstd/vector: improve append_range tests
Diffstat (limited to 'libs/kstd/tests/include')
-rw-r--r--libs/kstd/tests/include/kstd/tests/test_types.hpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/libs/kstd/tests/include/kstd/tests/test_types.hpp b/libs/kstd/tests/include/kstd/tests/test_types.hpp
index 9207ee9..8231fd3 100644
--- a/libs/kstd/tests/include/kstd/tests/test_types.hpp
+++ b/libs/kstd/tests/include/kstd/tests/test_types.hpp
@@ -239,17 +239,29 @@ namespace kstd::tests
struct test_input_iterator
{
using iterator_concept = std::input_iterator_tag;
+ using iterator_category = std::input_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = int;
+ using reference = int const &;
+ using pointer = int const *;
//! The current element pointed to by the iterator.
int const * current;
+ //! The number of elements in the range.
+ std::size_t count;
+
+ explicit test_input_iterator()
+ : current{nullptr}
+ , count{0}
+ {}
//! Construct a new test input iterator.
//!
//! @param current The current element pointed to by the iterator.
- constexpr explicit test_input_iterator(int const * current)
+ //! @param count The number of elements in the range.
+ explicit test_input_iterator(int const * current, std::size_t count)
: current{current}
+ , count{count}
{}
//! Dereference the iterator to get the current element.
@@ -266,6 +278,7 @@ namespace kstd::tests
auto operator++() -> test_input_iterator &
{
++current;
+ --count;
return *this;
}
@@ -281,7 +294,17 @@ namespace kstd::tests
//! @return True if the two test input iterators are equal, false otherwise.
[[nodiscard]] auto operator==(test_input_iterator const & other) const -> bool
{
- return current == other.current;
+ if (current == nullptr && other.current == nullptr)
+ {
+ return true;
+ }
+
+ if (current == nullptr || other.current == nullptr)
+ {
+ return count == other.count;
+ }
+
+ return current == other.current && count == other.count;
}
};