Skip to content

Commit

Permalink
Added iterator consistency test
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMabille committed Apr 16, 2024
1 parent b50417b commit 4172e60
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/test_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,40 @@ namespace sparrow
CHECK_EQ(citer, b.crend());
}

TEST_CASE("iterator_consistency")
{
const std::size_t size = 8u;
buffer_test_type b(make_test_buffer(size), size);

{
auto iter = --b.end();
auto riter = b.rbegin();
auto citer = --b.cend();
auto criter = b.crbegin();

while (iter != b.begin())
{
CHECK_EQ(*iter, *riter);
CHECK_EQ(*citer, *criter);
--iter, --citer, ++riter, ++criter;
}
}

{
auto iter = b.begin();
auto riter = --b.rend();
auto citer = b.cbegin();
auto criter = --b.crend();

while (iter != b.end())
{
CHECK_EQ(*iter, *riter);
CHECK_EQ(*citer, *criter);
++iter, ++citer, --riter, --criter;
}
}
}

// capacity

TEST_CASE("empty")
Expand Down

0 comments on commit 4172e60

Please sign in to comment.