Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gvinciguerra committed Apr 22, 2024
1 parent 8125b35 commit 9dcb6b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
21 changes: 4 additions & 17 deletions test/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ TEMPLATE_TEST_CASE_SIG("PGM-index", "",
((typename T, size_t E1, size_t E2), T, E1, E2),
(uint32_t, 8, 0), (uint32_t, 32, 0), (uint32_t, 128, 0),
(uint64_t, 8, 4), (uint64_t, 32, 4), (uint64_t, 128, 4),
(uint64_t, 256, 256), (uint64_t, 512, 512)) {
(int32_t, 8, 0), (int32_t, 32, 0), (int32_t, 128, 0),
(int64_t, 8, 4), (int64_t, 32, 4), (int64_t, 128, 4),
(int64_t, 1024, 1024), (uint64_t, 1024, 1024)) {
auto data = generate_data<T>(2000000);
pgm::PGMIndex<T, E1, E2> index(data.begin(), data.end());
test_index(index, data);
Expand All @@ -106,13 +108,6 @@ TEMPLATE_TEST_CASE_SIG("Bucketing PGM-index", "",
test_index(index, data);
}

TEMPLATE_TEST_CASE_SIG("Bucketing PGM-index edge case", "",
((size_t E, size_t S), E, S), (4, 128), (8, 100), (4, 512), (8, 550)) {
std::vector<uint32_t> data(2000000);
pgm::BucketingPGMIndex<uint32_t, E, S> index(data.begin(), data.end());
test_index(index, data);
}

TEMPLATE_TEST_CASE_SIG("Elias-Fano PGM-index", "", ((size_t E), E), 8, 32, 128) {
auto data = generate_data<uint32_t>(2000000);
pgm::EliasFanoPGMIndex<uint32_t, E> index(data.begin(), data.end());
Expand Down Expand Up @@ -273,12 +268,4 @@ TEMPLATE_TEST_CASE_SIG("Multidimensional PGM-index", "",
}
}

#endif

TEST_CASE("PGM-index out of bonds", "[tmg]")
{
std::vector<uint32_t> data { std::numeric_limits<uint32_t>::max() };

pgm::PGMIndex<uint32_t> index(data.begin(), data.end());
REQUIRE ( index.segments_count()==0 );
}
#endif
4 changes: 3 additions & 1 deletion test/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ std::vector<T> generate_data(size_t n) {
T min = 0;
if constexpr (std::is_signed_v<T>)
min = -10000;
auto value_min = std::numeric_limits<T>::min();
auto value_max = std::numeric_limits<T>::max() - 1;
RandomFunction uniform_dense = std::bind(std::uniform_int_distribution<T>(min, 10000), engine);
RandomFunction uniform_sparse = std::bind(std::uniform_int_distribution<T>(min, 10000000), engine);
RandomFunction uniform_sparse = std::bind(std::uniform_int_distribution<T>(value_min, value_max), engine);
RandomFunction binomial = std::bind(std::binomial_distribution<T>(50000), engine);
RandomFunction geometric = std::bind(std::geometric_distribution<T>(0.8), engine);
auto rand = GENERATE_COPY(as<RandomFunction>{}, uniform_dense, uniform_sparse, binomial, geometric);
Expand Down

0 comments on commit 9dcb6b1

Please sign in to comment.