From aac34bdbfd56d6c10c17560628d61a958b6abfa5 Mon Sep 17 00:00:00 2001 From: AlexanderSaydakov Date: Fri, 26 Jul 2024 17:56:11 -0700 Subject: [PATCH] cross-language test --- .../theta_sketch_deserialize_from_java_test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/theta/test/theta_sketch_deserialize_from_java_test.cpp b/theta/test/theta_sketch_deserialize_from_java_test.cpp index f69467eb..691320a4 100644 --- a/theta/test/theta_sketch_deserialize_from_java_test.cpp +++ b/theta/test/theta_sketch_deserialize_from_java_test.cpp @@ -45,6 +45,23 @@ TEST_CASE("theta sketch", "[serde_compat]") { } } +TEST_CASE("theta sketch compressed", "[serde_compat]") { + const unsigned n_arr[] = {10, 100, 1000, 10000, 100000, 1000000}; + for (const unsigned n: n_arr) { + std::ifstream is; + is.exceptions(std::ios::failbit | std::ios::badbit); + is.open(testBinaryInputPath + "theta_compressed_n" + std::to_string(n) + "_java.sk", std::ios::binary); + const auto sketch = compact_theta_sketch::deserialize(is); + REQUIRE(sketch.is_estimation_mode() == (n > 1000)); + REQUIRE(sketch.get_estimate() == Approx(n).margin(n * 0.03)); + for (const auto hash: sketch) { + REQUIRE(hash < sketch.get_theta64()); + } + REQUIRE(sketch.is_ordered()); + REQUIRE(std::is_sorted(sketch.begin(), sketch.end())); + } +} + TEST_CASE("theta sketch non-empty no entries", "[serde_compat]") { std::ifstream is; is.exceptions(std::ios::failbit | std::ios::badbit);