You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2020/07/14 21:19:41 UTC

[incubator-datasketches-cpp] branch tuple_sketch updated: better union tests

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch tuple_sketch
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git


The following commit(s) were added to refs/heads/tuple_sketch by this push:
     new 26e7f96  better union tests
26e7f96 is described below

commit 26e7f96b9a962bd36da4d90061599a95106658da
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Tue Jul 14 14:19:29 2020 -0700

    better union tests
---
 tuple/test/tuple_union_test.cpp | 50 +++++++++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 14 deletions(-)

diff --git a/tuple/test/tuple_union_test.cpp b/tuple/test/tuple_union_test.cpp
index fb49d4c..38289fd 100644
--- a/tuple/test/tuple_union_test.cpp
+++ b/tuple/test/tuple_union_test.cpp
@@ -78,13 +78,24 @@ TEST_CASE("tuple_union float: exact mode half overlap", "[tuple union]") {
   value = 500;
   for (int i = 0; i < 1000; ++i) update_sketch2.update(value++, 1);
 
-  auto u = tuple_union<float>::builder().build();
-  u.update(update_sketch1);
-  u.update(update_sketch2);
-  auto result = u.get_result();
-  REQUIRE(!result.is_empty());
-  REQUIRE(!result.is_estimation_mode());
-  REQUIRE(result.get_estimate() == Approx(1500).margin(1500 * 0.01));
+  { // unordered
+    auto u = tuple_union<float>::builder().build();
+    u.update(update_sketch1);
+    u.update(update_sketch2);
+    auto result = u.get_result();
+    REQUIRE(!result.is_empty());
+    REQUIRE(!result.is_estimation_mode());
+    REQUIRE(result.get_estimate() == Approx(1500).margin(1500 * 0.01));
+  }
+  { // ordered
+    auto u = tuple_union<float>::builder().build();
+    u.update(update_sketch1.compact());
+    u.update(update_sketch2.compact());
+    auto result = u.get_result();
+    REQUIRE(!result.is_empty());
+    REQUIRE(!result.is_estimation_mode());
+    REQUIRE(result.get_estimate() == Approx(1500).margin(1500 * 0.01));
+  }
 }
 
 TEST_CASE("tuple_union float: estimation mode half overlap", "[tuple union]") {
@@ -96,13 +107,24 @@ TEST_CASE("tuple_union float: estimation mode half overlap", "[tuple union]") {
   value = 5000;
   for (int i = 0; i < 10000; ++i) update_sketch2.update(value++, 1);
 
-  auto u = tuple_union<float>::builder().build();
-  u.update(update_sketch1);
-  u.update(update_sketch2);
-  auto result = u.get_result();
-  REQUIRE(!result.is_empty());
-  REQUIRE(result.is_estimation_mode());
-  REQUIRE(result.get_estimate() == Approx(15000).margin(15000 * 0.01));
+  { // unordered
+    auto u = tuple_union<float>::builder().build();
+    u.update(update_sketch1);
+    u.update(update_sketch2);
+    auto result = u.get_result();
+    REQUIRE(!result.is_empty());
+    REQUIRE(result.is_estimation_mode());
+    REQUIRE(result.get_estimate() == Approx(15000).margin(15000 * 0.01));
+  }
+  { // ordered
+    auto u = tuple_union<float>::builder().build();
+    u.update(update_sketch1.compact());
+    u.update(update_sketch2.compact());
+    auto result = u.get_result();
+    REQUIRE(!result.is_empty());
+    REQUIRE(result.is_estimation_mode());
+    REQUIRE(result.get_estimate() == Approx(15000).margin(15000 * 0.01));
+  }
 }
 
 TEST_CASE("tuple_union float: seed mismatch", "[tuple union]") {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org