This is an automated email from the ASF dual-hosted git repository.
alsay pushed a commit to branch cleanup_warnings
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
The following commit(s) were added to refs/heads/cleanup_warnings by this push:
new f7483d6 test with max lgk
f7483d6 is described below
commit f7483d6499e71d1b53beed0b1451abde421e35c4
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Mon Mar 22 19:02:24 2021 -0700
test with max lgk
---
cpc/test/cpc_sketch_test.cpp | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/cpc/test/cpc_sketch_test.cpp b/cpc/test/cpc_sketch_test.cpp
index 837a61d..0a2ca74 100644
--- a/cpc/test/cpc_sketch_test.cpp
+++ b/cpc/test/cpc_sketch_test.cpp
@@ -283,6 +283,26 @@ TEST_CASE("cpc sketch: serialize deserialize sliding,
bytes", "[cpc_sketch]") {
REQUIRE(deserialized.validate());
}
+TEST_CASE("cpc sketch: serialize deserialize sliding huge", "[cpc_sketch]") {
+ cpc_sketch sketch(26);
+ const int n = 10000000;
+ for (int i = 0; i < n; i++) sketch.update(i);
+ REQUIRE(sketch.get_estimate() == Approx(n).margin(n * 0.001));
+ auto bytes = sketch.serialize();
+ cpc_sketch deserialized = cpc_sketch::deserialize(bytes.data(),
bytes.size());
+ REQUIRE(deserialized.is_empty() == sketch.is_empty());
+ REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
+ REQUIRE(deserialized.validate());
+ REQUIRE_THROWS_AS(cpc_sketch::deserialize(bytes.data(), 7),
std::out_of_range);
+ REQUIRE_THROWS_AS(cpc_sketch::deserialize(bytes.data(), 15),
std::out_of_range);
+ REQUIRE_THROWS_AS(cpc_sketch::deserialize(bytes.data(), bytes.size() - 1),
std::out_of_range);
+
+ // updating again with the same values should not change the sketch
+ for (int i = 0; i < n; i++) deserialized.update(i);
+ REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
+ REQUIRE(deserialized.validate());
+}
+
TEST_CASE("cpc sketch: copy", "[cpc_sketch]") {
cpc_sketch s1(11);
s1.update(1);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]