aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd/tests/include
diff options
context:
space:
mode:
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;
}
};