From 338d9b2b6fc517df2135089699234232495324d6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 1 May 2026 13:11:37 +0200 Subject: kstd/vector: improve append_range tests --- libs/kstd/tests/include/kstd/tests/test_types.hpp | 27 +++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'libs/kstd/tests/include') 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; } }; -- cgit v1.2.3