Skip to content

Commit

Permalink
Include NaN in language compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalkin committed Aug 14, 2024
1 parent 6daa489 commit 505a119
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions filters/test/bloom_filter_deserialize_from_java_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ TEST_CASE("bloom_filter", "[serde_compat]") {
for (uint64_t i = 0; i < n / 10; ++i) {
REQUIRE(bf.query(i));
}
if (n > 0) REQUIRE(bf.query(std::nan("1")));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions filters/test/bloom_filter_serialize_for_java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ TEST_CASE("bloom filter generate", "[serialize_for_java]") {
const uint64_t config_bits = std::max(n, static_cast<uint64_t>(1000)); // so empty still has valid bit size
bloom_filter bf = bloom_filter_builder::create_by_size(config_bits, num_hashes);
for (uint64_t i = 0; i < n / 10; ++i) bf.update(i); // note: n / 10 items into n bits
if (n > 0) bf.update(std::nan("1")); // include a NaN if non-empty
REQUIRE(bf.is_empty() == (n == 0));
REQUIRE((bf.is_empty() || (bf.get_bits_used() > n / 10)));
std::ofstream os("bf_n" + std::to_string(n) + "_h" + std::to_string(num_hashes) + "_cpp.filter", std::ios::binary);
Expand Down

0 comments on commit 505a119

Please sign in to comment.