From d4c8b5ecccd100ebf6c6dde674a4d42656a1f935 Mon Sep 17 00:00:00 2001 From: Radu Nichita Date: Thu, 14 Nov 2024 01:43:47 +0100 Subject: [PATCH] tests: Add unit tests for repeated_chars_iterator --- .../iterator_interface/iterator_interface.test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/beman/iterator_interface/iterator_interface.test.cpp b/tests/beman/iterator_interface/iterator_interface.test.cpp index fb707a1..7b851e3 100644 --- a/tests/beman/iterator_interface/iterator_interface.test.cpp +++ b/tests/beman/iterator_interface/iterator_interface.test.cpp @@ -43,6 +43,18 @@ TEST(IteratorTest, TestRepeatedChars) { ASSERT_EQ(result, "foofoof"); } +TEST(IteratorTest, TestDistance) { + repeated_chars_iterator first("foo", 3, 0); // 3 is the length of "foo", 0 is this iterator's position. + repeated_chars_iterator last("foo", 3, 3); // 3 is the length of "foo", 3 is this iterator's position. + ASSERT_EQ(std::distance(first, last), 3); +} + +TEST(IteratorTest, TestNext) { + repeated_chars_iterator first("foo", 3, 0); // 3 is the length of "foo", 0 is this iterator's position. + repeated_chars_iterator last("foo", 3, 3); // 3 is the length of "foo", 3 is this iterator's position. + ASSERT_EQ(std::next(first, 3), last); +} + template struct filtered_int_iterator : ext_iterator_interface_compat, std::forward_iterator_tag, int> {