Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73661 - sandbox/bloom_filter/trunk/libs/bloom_filter/test
From: cpp.cabrera_at_[hidden]
Date: 2011-08-11 12:53:45


Author: alejandro
Date: 2011-08-11 12:53:44 EDT (Thu, 11 Aug 2011)
New Revision: 73661
URL: http://svn.boost.org/trac/boost/changeset/73661

Log:
Test fixes:

    - Cleaned up twohash regression tests.
    - Removed false_positive_rate test from
      two_hash_counting_bloom_filter.
Text files modified:
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_basic_bloom_filter-pass.cpp | 27 ++++++++++-----------
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_counting_bloom_filter-pass.cpp | 48 ++++++++++------------------------------
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_dynamic_basic_bloom_filter-pass.cpp | 25 ++++++++++----------
   3 files changed, 37 insertions(+), 63 deletions(-)

Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_basic_bloom_filter-pass.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_basic_bloom_filter-pass.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_basic_bloom_filter-pass.cpp 2011-08-11 12:53:44 EDT (Thu, 11 Aug 2011)
@@ -62,14 +62,14 @@
 
 BOOST_AUTO_TEST_CASE(rangeConstructor) {
   int elems[5] = {1,2,3,4,5};
- twohash_basic_bloom_filter<int, 8> bloom(elems, elems+5);
+ twohash_basic_bloom_filter<int, 8, 1> bloom(elems, elems+5);
 
   BOOST_CHECK_EQUAL(bloom.count(), 5ul);
 }
 
 #ifndef BOOST_NO_0X_HDR_INITIALIZER_LIST
 BOOST_AUTO_TEST_CASE(initListConstructor) {
- twohash_basic_bloom_filter<int, 8> bloom = {1,2,3,4,5};
+ twohash_basic_bloom_filter<int, 8, 1> bloom = {1,2,3,4,5};
 
   BOOST_CHECK_EQUAL(bloom.count(), 5ul);
 }
@@ -148,22 +148,21 @@
   BOOST_CHECK_EQUAL(bloom.false_positive_rate(), 0.0);
 
   bloom.insert(1);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.00094659, .01);
-
- bloom.insert(2);
   BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.0036708, .01);
 
+ bloom.insert(2);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.013807, .01);
   bloom.insert(3);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.0080084, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.029231, .01);
 
   bloom.insert(4);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.013807, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.048929, .01);
 
   bloom.insert(5);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.020925, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.072030, .01);
 
   bloom.insert(6);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.029231, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.084619, .01);
 
   for (size_t i = 7; i < 5000; ++i)
     bloom.insert(i);
@@ -198,7 +197,7 @@
 
 BOOST_AUTO_TEST_CASE(rangeInsert) {
   int elems[5] = {1,2,3,4,5};
- twohash_basic_bloom_filter<size_t, 8> bloom;
+ twohash_basic_bloom_filter<size_t, 8, 1> bloom;
 
   bloom.insert(elems, elems+5);
   BOOST_CHECK_EQUAL(bloom.count(), 5ul);
@@ -217,8 +216,8 @@
 
 BOOST_AUTO_TEST_CASE(memberSwap) {
   size_t elems[5] = {1,2,3,4,5};
- twohash_basic_bloom_filter<size_t, 8> bloom1(elems, elems+2);
- twohash_basic_bloom_filter<size_t, 8> bloom2(elems+2, elems+5);
+ twohash_basic_bloom_filter<size_t, 8, 1> bloom1(elems, elems+2);
+ twohash_basic_bloom_filter<size_t, 8, 1> bloom2(elems+2, elems+5);
 
   bloom1.swap(bloom2);
 
@@ -293,8 +292,8 @@
 
 BOOST_AUTO_TEST_CASE(globalSwap) {
   size_t elems[5] = {1,2,3,4,5};
- twohash_basic_bloom_filter<size_t, 8> bloom1(elems, elems+2);
- twohash_basic_bloom_filter<size_t, 8> bloom2(elems+2, elems+5);
+ twohash_basic_bloom_filter<size_t, 8, 1> bloom1(elems, elems+2);
+ twohash_basic_bloom_filter<size_t, 8, 1> bloom2(elems+2, elems+5);
 
   swap(bloom1, bloom2);
 

Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_counting_bloom_filter-pass.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_counting_bloom_filter-pass.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_counting_bloom_filter-pass.cpp 2011-08-11 12:53:44 EDT (Thu, 11 Aug 2011)
@@ -92,7 +92,7 @@
 
 BOOST_AUTO_TEST_CASE(countSingle)
 {
- twohash_counting_bloom_filter<int, 2> bloom;
+ twohash_counting_bloom_filter<int, 2, 4, 1> bloom;
   
   bloom.insert(1);
   BOOST_CHECK_EQUAL(bloom.count(), 1ul);
@@ -102,13 +102,13 @@
 
 BOOST_AUTO_TEST_CASE(countMulti)
 {
- twohash_counting_bloom_filter<int, 100> bloom_default;
- twohash_counting_bloom_filter<int, 100, 1> bloom1;
- twohash_counting_bloom_filter<int, 100, 2> bloom2;
- twohash_counting_bloom_filter<int, 100, 4> bloom4;
- twohash_counting_bloom_filter<int, 100, 8> bloom8;
- twohash_counting_bloom_filter<int, 100, 16> bloom16;
- twohash_counting_bloom_filter<int, 100, 32> bloom32;
+ twohash_counting_bloom_filter<int, 400, 4, 1> bloom_default;
+ twohash_counting_bloom_filter<int, 400, 1, 1> bloom1;
+ twohash_counting_bloom_filter<int, 400, 2, 1> bloom2;
+ twohash_counting_bloom_filter<int, 400, 4, 1> bloom4;
+ twohash_counting_bloom_filter<int, 400, 8, 1> bloom8;
+ twohash_counting_bloom_filter<int, 400, 16, 1> bloom16;
+ twohash_counting_bloom_filter<int, 400, 32, 1> bloom32;
 
   for (size_t i = 0; i < 100; ++i) {
     bloom_default.insert(i);
@@ -181,7 +181,7 @@
 
 BOOST_AUTO_TEST_CASE(rangeConstructor) {
   int elems[5] = {1,2,3,4,5};
- twohash_counting_bloom_filter<int, 5> bloom(elems, elems+5);
+ twohash_counting_bloom_filter<int, 5, 4, 1> bloom(elems, elems+5);
 
   BOOST_CHECK_EQUAL(bloom.count(), 5ul);
 }
@@ -252,32 +252,8 @@
   BOOST_CHECK_EQUAL(bloom_7h.num_hash_functions(), 7ul);
 }
 
-BOOST_AUTO_TEST_CASE(falsePositiveRate) {
- twohash_counting_bloom_filter<size_t, 64> bloom;
-
- BOOST_CHECK_EQUAL(bloom.false_positive_rate(), 0.0);
-
- bloom.insert(1);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.00094659, .01);
-
- bloom.insert(2);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.0036708, .01);
-
- bloom.insert(3);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.0080084, .01);
-
- bloom.insert(4);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.013807, .01);
-
- bloom.insert(5);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.020925, .01);
-
- bloom.insert(6);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.029231, .01);
-}
-
 BOOST_AUTO_TEST_CASE(probably_contains) {
- twohash_counting_bloom_filter<size_t, 2> bloom;
+ twohash_counting_bloom_filter<size_t, 2, 4, 1> bloom;
 
   bloom.insert(1);
   BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
@@ -409,8 +385,8 @@
   }
 
   size_t elems[5];
- twohash_counting_bloom_filter<size_t, 5> bloom1;
- twohash_counting_bloom_filter<size_t, 5> bloom2;
+ twohash_counting_bloom_filter<size_t, 5, 4, 1> bloom1;
+ twohash_counting_bloom_filter<size_t, 5, 4, 1> bloom2;
 };
 
 BOOST_FIXTURE_TEST_CASE(memberSwap, SwapFixture) {

Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_dynamic_basic_bloom_filter-pass.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_dynamic_basic_bloom_filter-pass.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_dynamic_basic_bloom_filter-pass.cpp 2011-08-11 12:53:44 EDT (Thu, 11 Aug 2011)
@@ -99,7 +99,7 @@
 
 BOOST_AUTO_TEST_CASE(rangeConstructor) {
   int elems[5] = {1,2,3,4,5};
- twohash_dynamic_basic_bloom_filter<int> bloom(elems, elems+5);
+ twohash_dynamic_basic_bloom_filter<int, 1> bloom(elems, elems+5);
 
   BOOST_CHECK_EQUAL(bloom.count(), 5ul);
 }
@@ -177,22 +177,21 @@
   BOOST_CHECK_EQUAL(bloom.false_positive_rate(), 0.0);
 
   bloom.insert(1);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.00094659, .01);
-
- bloom.insert(2);
   BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.0036708, .01);
 
+ bloom.insert(2);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.013807, .01);
   bloom.insert(3);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.0080084, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.029231, .01);
 
   bloom.insert(4);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.013807, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.048929, .01);
 
   bloom.insert(5);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.020925, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.072030, .01);
 
   bloom.insert(6);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.029231, .01);
+ BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.084619, .01);
 
   for (size_t i = 7; i < 5000; ++i)
     bloom.insert(i);
@@ -227,7 +226,7 @@
 
 BOOST_AUTO_TEST_CASE(rangeInsert) {
   int elems[5] = {1,2,3,4,5};
- twohash_dynamic_basic_bloom_filter<size_t> bloom(8);
+ twohash_dynamic_basic_bloom_filter<size_t, 1> bloom(8);
 
   bloom.insert(elems, elems+5);
   BOOST_CHECK_EQUAL(bloom.count(), 5ul);
@@ -246,8 +245,8 @@
 
 BOOST_AUTO_TEST_CASE(memberSwap) {
   size_t elems[5] = {1,2,3,4,5};
- twohash_dynamic_basic_bloom_filter<size_t> bloom1(elems, elems+2);
- twohash_dynamic_basic_bloom_filter<size_t> bloom2(elems+2, elems+5);
+ twohash_dynamic_basic_bloom_filter<size_t, 1> bloom1(elems, elems+2);
+ twohash_dynamic_basic_bloom_filter<size_t, 1> bloom2(elems+2, elems+5);
 
   bloom1.swap(bloom2);
 
@@ -322,8 +321,8 @@
 
 BOOST_AUTO_TEST_CASE(globalSwap) {
   size_t elems[5] = {1,2,3,4,5};
- twohash_dynamic_basic_bloom_filter<size_t> bloom1(elems, elems+2);
- twohash_dynamic_basic_bloom_filter<size_t> bloom2(elems+2, elems+5);
+ twohash_dynamic_basic_bloom_filter<size_t, 1> bloom1(elems, elems+2);
+ twohash_dynamic_basic_bloom_filter<size_t, 1> bloom2(elems+2, elems+5);
 
   swap(bloom1, bloom2);
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk