Skip to content

Commit

Permalink
Add test for fixed_size_layout's iterators (#60)
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan authored Apr 4, 2024
1 parent dbbfd27 commit e423d1f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set(SPARROW_TESTS_SOURCES
test_buffer.cpp
test_dynamic_bitset.cpp
test_iterator.cpp
test_layout.cpp
test_fixed_size_layout.cpp
test_variable_size_binary_layout.cpp
test_dictionary_encoded_layout.cpp
)
Expand Down
49 changes: 49 additions & 0 deletions test/test_layout.cpp → test/test_fixed_size_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,55 @@ namespace sparrow
CHECK_EQ(citer, lt_values.end());
}

TEST_CASE("const_value_iterator_ordering")
{
layout_test_type lt(make_test_array_data(10, 1));
auto lt_values = lt.values();
layout_test_type::const_value_iterator citer = lt_values.begin();
CHECK(citer < lt_values.end());
}

TEST_CASE("const_value_iterator_equality")
{
layout_test_type lt(make_test_array_data(10, 1));
auto lt_values = lt.values();
for (std::size_t i = 0; i < lt.size(); ++i)
{
lt[i] = i;
}

layout_test_type::const_value_iterator citer = lt_values.begin();
for (std::size_t i = 0; i < lt.size(); ++i, ++citer)
{
CHECK_EQ(*citer, i);
}
}

TEST_CASE("const_bitmap_iterator_ordering")
{
layout_test_type lt(make_test_array_data(10, 1));
auto lt_bitmap = lt.bitmap();
layout_test_type::const_bitmap_iterator citer = lt_bitmap.begin();
CHECK(citer < lt_bitmap.end());
}

TEST_CASE("const_bitmap_iterator_equality")
{
layout_test_type lt(make_test_array_data(10, 1));
auto lt_bitmap = lt.bitmap();
for (std::size_t i = 0; i < lt.size(); ++i)
{
if (i % 2 != 0)
lt[i] = std::nullopt;
}

layout_test_type::const_bitmap_iterator citer = lt_bitmap.begin();
for (std::size_t i = 0; i < lt.size(); ++i, ++citer)
{
CHECK_EQ(*citer, i % 2 == 0);
}
}

TEST_CASE("iterator")
{
layout_test_type lt(make_test_array_data(10, 1));
Expand Down

0 comments on commit e423d1f

Please sign in to comment.