Skip to content

Commit d4c8b5e

Browse files
committed
tests: Add unit tests for repeated_chars_iterator
1 parent fed466b commit d4c8b5e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/beman/iterator_interface/iterator_interface.test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ TEST(IteratorTest, TestRepeatedChars) {
4343
ASSERT_EQ(result, "foofoof");
4444
}
4545

46+
TEST(IteratorTest, TestDistance) {
47+
repeated_chars_iterator first("foo", 3, 0); // 3 is the length of "foo", 0 is this iterator's position.
48+
repeated_chars_iterator last("foo", 3, 3); // 3 is the length of "foo", 3 is this iterator's position.
49+
ASSERT_EQ(std::distance(first, last), 3);
50+
}
51+
52+
TEST(IteratorTest, TestNext) {
53+
repeated_chars_iterator first("foo", 3, 0); // 3 is the length of "foo", 0 is this iterator's position.
54+
repeated_chars_iterator last("foo", 3, 3); // 3 is the length of "foo", 3 is this iterator's position.
55+
ASSERT_EQ(std::next(first, 3), last);
56+
}
57+
4658
template <typename Pred>
4759
struct filtered_int_iterator
4860
: ext_iterator_interface_compat<filtered_int_iterator<Pred>, std::forward_iterator_tag, int> {

0 commit comments

Comments
 (0)