Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73710 - sandbox/bloom_filter/trunk/libs/bloom_filter/test
From: cpp.cabrera_at_[hidden]
Date: 2011-08-13 01:10:26


Author: alejandro
Date: 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
New Revision: 73710
URL: http://svn.boost.org/trac/boost/changeset/73710

Log:
New test:
  - twohash_dynamic_counting_bloom_filter-pass.cpp

Updates:
  - Removed intersect/union exception tests
    from dynamic_counting_bloom_filter.
  - Removed union/intersect tests for counting_bloom_filter.
  - Split regression into two suites - twohash and original.

Renaming:
  - bloom-pass.cpp -> basic_bloom_filter-pass.cpp
  - counting_bloom-pass.cpp -> counting_bloom_filter-pass.cpp
  - dynamic_bloom-pass.cpp -> dynamic_bloom_filter-pass.cpp
  - dynamic_counting_bloom-pass.cpp
    -> dynamic_counting_bloom_filter-pass.cpp
Added:
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/basic_bloom_filter-pass.cpp (contents, props changed)
      - copied, changed from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom-pass.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom_filter-pass.cpp (contents, props changed)
      - copied, changed from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom-pass.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_bloom_filter-pass.cpp (contents, props changed)
      - copied, changed from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_bloom-pass.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom_filter-pass.cpp (contents, props changed)
      - copied, changed from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom-pass.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_dynamic_counting_bloom_filter-pass.cpp (contents, props changed)
Removed:
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom-pass.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom-pass.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_bloom-pass.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom-pass.cpp
Text files modified:
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2 | 14 ++-
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom_filter-pass.cpp | 101 -----------------------
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom_filter-pass.cpp | 171 ----------------------------------------
   3 files changed, 9 insertions(+), 277 deletions(-)

Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2 (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
@@ -22,12 +22,16 @@
 
     test-suite "regression"
         :
- [ run bloom-pass.cpp ]
- [ run dynamic_bloom-pass.cpp ]
- [ run counting_bloom-pass.cpp ]
- [ run dynamic_counting_bloom-pass.cpp ]
+ [ run basic_bloom_filter-pass.cpp ]
+ [ run dynamic_bloom_filter-pass.cpp ]
+ [ run counting_bloom_filter-pass.cpp ]
+ [ run dynamic_counting_bloom_filter-pass.cpp ]
+ ;
+
+ test-suite "twohash_regression"
+ :
         [ run twohash_basic_bloom_filter-pass.cpp ]
         [ run twohash_dynamic_basic_bloom_filter-pass.cpp ]
         [ run twohash_counting_bloom_filter-pass.cpp ]
+ [ run twohash_dynamic_counting_bloom_filter-pass.cpp ]
         ;
-

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/basic_bloom_filter-pass.cpp (from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom-pass.cpp)
==============================================================================

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom-pass.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom-pass.cpp 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
+++ (empty file)
@@ -1,293 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Alejandro Cabrera 2011.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/bloom_filter for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#define BOOST_TEST_DYN_LINK 1
-#define BOOST_TEST_MODULE "Boost Bloom Filter" 1
-#include <iostream>
-
-#include <boost/bloom_filter/basic_bloom_filter.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-
-using boost::bloom_filters::basic_bloom_filter;
-using boost::bloom_filters::boost_hash;
-
-BOOST_AUTO_TEST_CASE(defaultConstructor) {
- typedef boost::mpl::vector<
- boost_hash<int, 13>,
- boost_hash<int, 17>,
- boost_hash<int, 19> > BoostHashFunctions;
-
- basic_bloom_filter<int, 8> bloom1;
- basic_bloom_filter<int, 8, BoostHashFunctions> bloom2;
-}
-
-BOOST_AUTO_TEST_CASE(rangeConstructor) {
- int elems[5] = {1,2,3,4,5};
- basic_bloom_filter<int, 8> bloom(elems, elems+5);
-
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-#ifndef BOOST_NO_0X_HDR_INITIALIZER_LIST
-BOOST_AUTO_TEST_CASE(initListConstructor) {
- basic_bloom_filter<int, 8> bloom = {1,2,3,4,5};
-
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-#endif
-
-BOOST_AUTO_TEST_CASE(copyConstructor) {
- int elems[5] = {1,2,3,4,5};
- basic_bloom_filter<int, 8> bloom1(elems, elems+5);
- basic_bloom_filter<int, 8> bloom2(bloom1);
-
- BOOST_CHECK_EQUAL(bloom1.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(assignment)
-{
- basic_bloom_filter<int, 8> bloom1;
- basic_bloom_filter<int, 8> bloom2;
-
- for (size_t i = 0; i < 200; ++i) {
- bloom1.insert(i);
- BOOST_CHECK_EQUAL(bloom1.probably_contains(i), true);
- }
-
- bloom2 = bloom1;
-
- for (size_t i = 0; i < 200; ++i) {
- BOOST_CHECK_EQUAL(bloom2.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(bit_capacity) {
- basic_bloom_filter<size_t, 8> bloom_8;
- basic_bloom_filter<size_t, 256> bloom_256;
- basic_bloom_filter<size_t, 2048> bloom_2048;
-
- BOOST_CHECK_EQUAL(bloom_8.bit_capacity(), 8ul);
- BOOST_CHECK_EQUAL(bloom_256.bit_capacity(), 256ul);
- BOOST_CHECK_EQUAL(bloom_2048.bit_capacity(), 2048ul);
-}
-
-BOOST_AUTO_TEST_CASE(empty) {
- basic_bloom_filter<size_t, 8> bloom;
-
- BOOST_CHECK_EQUAL(bloom.empty(), true);
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.empty(), false);
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.empty(), true);
-}
-
-BOOST_AUTO_TEST_CASE(numHashFunctions) {
- basic_bloom_filter<size_t, 8> bloom_3;
- basic_bloom_filter<size_t, 8, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2> > > bloom_2;
- basic_bloom_filter<size_t, 8, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2>,
- boost_hash<size_t, 3>,
- boost_hash<size_t, 4>,
- boost_hash<size_t, 5>,
- boost_hash<size_t, 6>,
- boost_hash<size_t, 7> > > bloom_7;
-
- BOOST_CHECK_EQUAL(bloom_3.num_hash_functions(), 1ul);
- BOOST_CHECK_EQUAL(bloom_2.num_hash_functions(), 2ul);
- BOOST_CHECK_EQUAL(bloom_7.num_hash_functions(), 7ul);
-}
-
-BOOST_AUTO_TEST_CASE(falsePositiveRate) {
- basic_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.015504, .01);
-
- bloom.insert(2);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.030768, .01);
-
- bloom.insert(3);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.045794, .01);
-
- bloom.insert(4);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.060588, .01);
-
- bloom.insert(5);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.075151, .01);
-
- bloom.insert(6);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.089491, .01);
-
- for (size_t i = 7; i < 5000; ++i)
- bloom.insert(i);
-
- BOOST_CHECK_GE(bloom.false_positive_rate(), 0.6);
- BOOST_CHECK_LE(bloom.false_positive_rate(), 1.0);
-}
-
-BOOST_AUTO_TEST_CASE(probably_contains) {
- basic_bloom_filter<size_t, 8> bloom;
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
- BOOST_CHECK_LE(bloom.count(), 3ul);
- BOOST_CHECK_GE(bloom.count(), 1ul);
-}
-
-BOOST_AUTO_TEST_CASE(doesNotContain) {
- basic_bloom_filter<size_t, 8> bloom;
-
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
-}
-
-BOOST_AUTO_TEST_CASE(insertNoFalseNegatives) {
- basic_bloom_filter<size_t, 2048> bloom;
-
- for (size_t i = 0; i < 100; ++i) {
- bloom.insert(i);
- BOOST_CHECK_EQUAL(bloom.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(rangeInsert) {
- int elems[5] = {1,2,3,4,5};
- basic_bloom_filter<size_t, 8> bloom;
-
- bloom.insert(elems, elems+5);
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-BOOST_AUTO_TEST_CASE(clear) {
- basic_bloom_filter<size_t, 8> bloom;
-
- for (size_t i = 0; i < 1000; ++i)
- bloom.insert(i);
-
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(memberSwap) {
- size_t elems[5] = {1,2,3,4,5};
- basic_bloom_filter<size_t, 8> bloom1(elems, elems+2);
- basic_bloom_filter<size_t, 8> bloom2(elems+2, elems+5);
-
- bloom1.swap(bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
-}
-
-BOOST_AUTO_TEST_CASE(testUnion) {
- basic_bloom_filter<size_t, 300> bloom_1;
- basic_bloom_filter<size_t, 300> bloom_2;
- basic_bloom_filter<size_t, 300> bloom_union;
-
- for (size_t i = 0; i < 100; ++i)
- bloom_1.insert(i);
-
- for (size_t i = 100; i < 200; ++i)
- bloom_2.insert(i);
-
- bloom_union = bloom_1 | bloom_2;
-
- for (size_t i = 0; i < 200; ++i)
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(i), true);
- BOOST_CHECK_GE(bloom_union.count(), bloom_1.count());
- BOOST_CHECK_GE(bloom_union.count(), bloom_2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testUnionAssign) {
- basic_bloom_filter<size_t, 300> bloom_1;
- basic_bloom_filter<size_t, 300> bloom_union;
-
- for (size_t i = 0; i < 100; ++i)
- bloom_1.insert(i);
-
- bloom_union |= bloom_1;
-
- for (size_t i = 0; i < 100; ++i)
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(i), true);
- BOOST_CHECK_EQUAL(bloom_union.count(), bloom_1.count());
-}
-
-BOOST_AUTO_TEST_CASE(testIntersect) {
- basic_bloom_filter<size_t, 300> bloom_1;
- basic_bloom_filter<size_t, 300> bloom_2;
- basic_bloom_filter<size_t, 300> bloom_intersect;
-
- // overlap at 100
- for (size_t i = 0; i < 101; ++i)
- bloom_1.insert(i);
-
- for (size_t i = 100; i < 200; ++i)
- bloom_2.insert(i);
-
- bloom_intersect = bloom_1 & bloom_2;
-
- BOOST_CHECK_LE(bloom_intersect.count(), bloom_1.count());
- BOOST_CHECK_LE(bloom_intersect.count(), bloom_2.count());
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(100), true);
-}
-
-BOOST_AUTO_TEST_CASE(testIntersectAssign) {
- basic_bloom_filter<size_t, 300> bloom_1;
- basic_bloom_filter<size_t, 300> bloom_intersect;
-
- for (size_t i = 0; i < 100; ++i)
- bloom_1.insert(i);
-
- bloom_intersect &= bloom_1;
-
- for (size_t i = 0; i < 100; ++i)
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(i), false);
-}
-
-BOOST_AUTO_TEST_CASE(globalSwap) {
- size_t elems[5] = {1,2,3,4,5};
- basic_bloom_filter<size_t, 8> bloom1(elems, elems+2);
- basic_bloom_filter<size_t, 8> bloom2(elems+2, elems+5);
-
- swap(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
-}
-
-BOOST_AUTO_TEST_CASE(equalityOperator) {
- basic_bloom_filter<int, 8> bloom1;
- basic_bloom_filter<int, 8> bloom2;
-
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, false);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
-}
-
-BOOST_AUTO_TEST_CASE(inequalityOperator) {
- basic_bloom_filter<int, 8> bloom1;
- basic_bloom_filter<int, 8> bloom2;
-
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, true);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
-}

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom-pass.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom-pass.cpp 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
+++ (empty file)
@@ -1,537 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Alejandro Cabrera 2011.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/bloom_filter for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#define BOOST_TEST_DYN_LINK 1
-#define BOOST_TEST_MODULE "Boost Bloom Filter" 1
-
-#include <boost/bloom_filter/counting_bloom_filter.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-
-#include <boost/bloom_filter/detail/exceptions.hpp>
-
-#include <boost/cstdint.hpp>
-
-using boost::bloom_filters::counting_bloom_filter;
-using boost::bloom_filters::detail::bin_underflow_exception;
-using boost::bloom_filters::detail::bin_overflow_exception;
-using boost::bloom_filters::boost_hash;
-
-BOOST_AUTO_TEST_CASE(allBitsPerBinCompile)
-{
- counting_bloom_filter<size_t, 2, 1> bloom1;
- counting_bloom_filter<size_t, 2, 2> bloom2;
- counting_bloom_filter<size_t, 2, 4> bloom4;
- counting_bloom_filter<size_t, 2, 8> bloom8;
- counting_bloom_filter<size_t, 2, 16> bloom16;
- counting_bloom_filter<size_t, 2, 32> bloom32;
-}
-
-BOOST_AUTO_TEST_CASE(allReasonableBlockTypesCompile)
-{
- typedef boost::mpl::vector<boost_hash<int, 0> > default_hash;
-
- counting_bloom_filter<int, 2, 2, default_hash, unsigned char> a;
- counting_bloom_filter<int, 2, 2, default_hash, unsigned short> b;
- counting_bloom_filter<int, 2, 2, default_hash, unsigned int> c;
- counting_bloom_filter<int, 2, 2, default_hash, unsigned long> d;
- counting_bloom_filter<int, 2, 2, default_hash, size_t> e;
-
- counting_bloom_filter<int, 2, 2, default_hash, uint8_t> aa;
- counting_bloom_filter<int, 2, 2, default_hash, uint16_t> ab;
- counting_bloom_filter<int, 2, 2, default_hash, uint32_t> ac;
- counting_bloom_filter<int, 2, 2, default_hash, uintmax_t> ad;
-}
-
-BOOST_AUTO_TEST_CASE(defaultConstructor) {
- typedef boost::mpl::vector<
- boost_hash<int, 13>,
- boost_hash<int, 17>,
- boost_hash<int, 19> > BoostHashFunctions;
-
- counting_bloom_filter<int, 2> bloom1;
- counting_bloom_filter<int, 2, 1> bloom2;
- counting_bloom_filter<int, 2, 2, BoostHashFunctions> bloom3;
- counting_bloom_filter<int, 2, 4,
- BoostHashFunctions, unsigned char> bloom4;
-}
-
-BOOST_AUTO_TEST_CASE(countSingle)
-{
- counting_bloom_filter<int, 2> bloom;
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.count(), 1ul);
- bloom.remove(1);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-#include <iostream>
-
-BOOST_AUTO_TEST_CASE(countMulti)
-{
- counting_bloom_filter<int, 100> bloom_default;
- counting_bloom_filter<int, 100, 1> bloom1;
- counting_bloom_filter<int, 100, 2> bloom2;
- counting_bloom_filter<int, 100, 8> bloom8;
- counting_bloom_filter<int, 100, 16> bloom16;
- counting_bloom_filter<int, 100, 32> bloom32;
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.insert(i);
- bloom1.insert(i);
- bloom2.insert(i);
- bloom8.insert(i);
- bloom16.insert(i);
- bloom32.insert(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom1.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.insert(i);
- bloom2.insert(i);
- bloom8.insert(i);
- bloom16.insert(i);
- bloom32.insert(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.remove(i);
- bloom2.remove(i);
- bloom8.remove(i);
- bloom16.remove(i);
- bloom32.remove(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.remove(i);
- bloom1.remove(i);
- bloom2.remove(i);
- bloom8.remove(i);
- bloom16.remove(i);
- bloom32.remove(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom1.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(rangeConstructor) {
- int elems[5] = {1,2,3,4,5};
- counting_bloom_filter<int, 5> bloom(elems, elems+5);
-
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-#ifndef BOOST_NO_0X_HDR_INITIALIZER_LIST
-BOOST_AUTO_TEST_CASE(initListConstructor) {
- counting_bloom_filter<int, 5> bloom = {1,2,3,4,5};
-
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-#endif
-
-BOOST_AUTO_TEST_CASE(copyConstructor) {
- int elems[5] = {1,2,3,4,5};
- counting_bloom_filter<int, 5> bloom1(elems, elems+5);
- counting_bloom_filter<int, 5> bloom2(bloom1);
-
- BOOST_CHECK_EQUAL(bloom1.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(assignment)
-{
- counting_bloom_filter<int, 200> bloom1;
- counting_bloom_filter<int, 200> bloom2;
-
- for (size_t i = 0; i < 200; ++i) {
- bloom1.insert(i);
- BOOST_CHECK_EQUAL(bloom1.probably_contains(i), true);
- }
-
- bloom2 = bloom1;
-
- for (size_t i = 0; i < 200; ++i) {
- BOOST_CHECK_EQUAL(bloom2.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(bit_capacity) {
- counting_bloom_filter<size_t, 8> bloom_8;
- counting_bloom_filter<size_t, 256> bloom_256;
- counting_bloom_filter<size_t, 2048> bloom_2048;
-
- BOOST_CHECK_EQUAL(bloom_8.bit_capacity(),
- 8ul * bloom_8.bits_per_bin());
- BOOST_CHECK_EQUAL(bloom_256.bit_capacity(),
- 256ul * bloom_256.bits_per_bin());
- BOOST_CHECK_EQUAL(bloom_2048.bit_capacity(),
- 2048ul * bloom_2048.bits_per_bin());
-}
-
-BOOST_AUTO_TEST_CASE(empty) {
- counting_bloom_filter<size_t, 2> bloom;
-
- BOOST_CHECK_EQUAL(bloom.empty(), true);
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.empty(), false);
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.empty(), true);
-}
-
-BOOST_AUTO_TEST_CASE(numHashFunctions) {
- counting_bloom_filter<size_t, 1> bloom_1;
- counting_bloom_filter<size_t, 1, 1, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2> > > bloom_2;
- counting_bloom_filter<size_t, 1, 1, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2>,
- boost_hash<size_t, 3>,
- boost_hash<size_t, 4>,
- boost_hash<size_t, 5>,
- boost_hash<size_t, 6>,
- boost_hash<size_t, 7> > > bloom_7;
-
- BOOST_CHECK_EQUAL(bloom_1.num_hash_functions(), 1ul);
- BOOST_CHECK_EQUAL(bloom_2.num_hash_functions(), 2ul);
- BOOST_CHECK_EQUAL(bloom_7.num_hash_functions(), 7ul);
-}
-
-BOOST_AUTO_TEST_CASE(falsePositiveRate) {
- 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.015504, .01);
-
- bloom.insert(2);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.030768, .01);
-
- bloom.insert(3);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.045794, .01);
-
- bloom.insert(4);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.060588, .01);
-
- bloom.insert(5);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.075151, .01);
-
- bloom.insert(6);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.089491, .01);
-
- for (size_t i = 7; i < 128; ++i)
- bloom.insert(i);
-
- BOOST_CHECK_GE(bloom.false_positive_rate(), 0.6);
- BOOST_CHECK_LE(bloom.false_positive_rate(), 1.0);
-}
-
-BOOST_AUTO_TEST_CASE(probably_contains) {
- counting_bloom_filter<size_t, 2> bloom;
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom.count(), 1ul);
-}
-
-BOOST_AUTO_TEST_CASE(doesNotContain) {
- counting_bloom_filter<size_t, 2> bloom;
-
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
-}
-
-BOOST_AUTO_TEST_CASE(insertNoFalseNegatives) {
- counting_bloom_filter<size_t, 100> bloom;
-
- for (size_t i = 0; i < 100; ++i) {
- bloom.insert(i);
- BOOST_CHECK_EQUAL(bloom.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(insertOverflowExceptionThrown) {
- counting_bloom_filter<size_t, 2, 1> bloom;
- bool exception_occurred = false;
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
-
- try {
- bloom.insert(1);
- }
-
- catch (bin_overflow_exception e) {
- exception_occurred = true;
- }
-
- BOOST_CHECK_EQUAL(exception_occurred, true);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
-}
-
-BOOST_AUTO_TEST_CASE(removeUnderflowExceptionThrown) {
- counting_bloom_filter<size_t, 2, 1> bloom;
- bool exception_occurred = false;
-
- try {
- bloom.remove(1);
- }
-
- catch (bin_underflow_exception e) {
- exception_occurred = true;
- }
-
- BOOST_CHECK_EQUAL(exception_occurred, true);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
-}
-
-BOOST_AUTO_TEST_CASE(insertOverflowException4bit)
-{
- counting_bloom_filter<size_t, 2> bloom;
- bool exception_occurred = false;
-
- try {
- for (size_t i = 0; i < (1ul << bloom.bits_per_bin()); ++i)
- bloom.insert(1);
- }
-
- catch (bin_overflow_exception e) {
- exception_occurred = true;
- }
-
- BOOST_CHECK_EQUAL(exception_occurred, true);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
-}
-
-BOOST_AUTO_TEST_CASE(rangeInsert) {
- int elems[5] = {1,2,3,4,5};
- counting_bloom_filter<size_t, 5> bloom;
-
- bloom.insert(elems, elems+5);
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-BOOST_AUTO_TEST_CASE(_remove) {
- counting_bloom_filter<size_t, 1> bloom;
-
- bloom.insert(1);
- bloom.remove(1);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(removeMulti) {
- counting_bloom_filter<size_t, 100> bloom;
-
- for (size_t i = 0; i < 100; ++i) {
- bloom.insert(i);
- bloom.remove(i);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
- }
-}
-
-BOOST_AUTO_TEST_CASE(rangeRemove) {
- size_t arr[] = {1,2,3,4,5};
- counting_bloom_filter<size_t, 5> bloom;
-
- bloom.insert(arr, arr+5);
- bloom.remove(arr, arr+5);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(clear) {
- counting_bloom_filter<size_t, 1000> bloom;
-
- for (size_t i = 0; i < 1000; ++i)
- bloom.insert(i);
-
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-struct SwapFixture {
- SwapFixture()
- {
- for (size_t i = 0; i < 5; ++i)
- elems[i] = i+1;
-
- bloom1.insert(elems, elems+2);
- bloom2.insert(elems+2, elems+5);
- }
-
- size_t elems[5];
- counting_bloom_filter<size_t, 5> bloom1;
- counting_bloom_filter<size_t, 5> bloom2;
-};
-
-BOOST_FIXTURE_TEST_CASE(memberSwap, SwapFixture) {
- bloom1.swap(bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
-}
-
-BOOST_FIXTURE_TEST_CASE(globalSwap, SwapFixture) {
- swap(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
-}
-
-struct PairwiseOpsFixture {
-
- PairwiseOpsFixture() {}
-
- counting_bloom_filter<size_t, 300> bloom1;
- counting_bloom_filter<size_t, 300> bloom2;
- counting_bloom_filter<size_t, 300> bloom_result;
-};
-
-BOOST_AUTO_TEST_CASE(testUnion) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom2;
- counting_bloom_filter<size_t, 4, 2> bloom_union;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_union = experimental_union(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_GE(bloom_union.count(), bloom1.count());
- BOOST_CHECK_GE(bloom_union.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testUnionAssign) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom_union;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
-
- bloom_union.insert(1);
- bloom_union.insert(3);
- bloom_union.insert(3);
-
- bloom_union.experimental_union_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_union.count(), 3ul);
-}
-
-BOOST_AUTO_TEST_CASE(testIntersect) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom2;
- counting_bloom_filter<size_t, 4, 2> bloom_intersect;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_intersect = experimental_intersect(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_LE(bloom_intersect.count(), bloom1.count());
- BOOST_CHECK_LE(bloom_intersect.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testIntersectAssign) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom_intersect;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
-
- bloom1.insert(0);
- bloom1.insert(0);
- bloom_intersect.insert(1);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
-
- bloom_intersect.experimental_intersect_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_intersect.count(), 2ul);
-}
-
-BOOST_FIXTURE_TEST_CASE(equalityOperator, PairwiseOpsFixture) {
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, false);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
-}
-
-BOOST_FIXTURE_TEST_CASE(inequalityOperator, PairwiseOpsFixture) {
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, true);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
-}

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom_filter-pass.cpp (from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom-pass.cpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom-pass.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/counting_bloom_filter-pass.cpp 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
@@ -419,107 +419,6 @@
   counting_bloom_filter<size_t, 300> bloom_result;
 };
 
-BOOST_AUTO_TEST_CASE(testUnion) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom2;
- counting_bloom_filter<size_t, 4, 2> bloom_union;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_union = experimental_union(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_GE(bloom_union.count(), bloom1.count());
- BOOST_CHECK_GE(bloom_union.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testUnionAssign) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom_union;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
-
- bloom_union.insert(1);
- bloom_union.insert(3);
- bloom_union.insert(3);
-
- bloom_union.experimental_union_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_union.count(), 3ul);
-}
-
-BOOST_AUTO_TEST_CASE(testIntersect) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom2;
- counting_bloom_filter<size_t, 4, 2> bloom_intersect;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_intersect = experimental_intersect(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_LE(bloom_intersect.count(), bloom1.count());
- BOOST_CHECK_LE(bloom_intersect.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testIntersectAssign) {
- counting_bloom_filter<size_t, 4, 2> bloom1;
- counting_bloom_filter<size_t, 4, 2> bloom_intersect;
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
-
- bloom1.insert(0);
- bloom1.insert(0);
- bloom_intersect.insert(1);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
-
- bloom_intersect.experimental_intersect_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_intersect.count(), 2ul);
-}
-
 BOOST_FIXTURE_TEST_CASE(equalityOperator, PairwiseOpsFixture) {
   BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
   bloom1.insert(1);

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_bloom-pass.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_bloom-pass.cpp 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
+++ (empty file)
@@ -1,336 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Alejandro Cabrera 2011.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/bloom_filter for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#define BOOST_TEST_DYN_LINK 1
-#define BOOST_TEST_MODULE "Boost Dynamic Bloom Filter" 1
-#include <iostream>
-
-#include <boost/bloom_filter/dynamic_bloom_filter.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-
-using boost::bloom_filters::dynamic_bloom_filter;
-using boost::bloom_filters::boost_hash;
-using boost::bloom_filters::detail::incompatible_size_exception;
-
-BOOST_AUTO_TEST_CASE(defaultConstructor) {
- typedef boost::mpl::vector<
- boost_hash<int, 13>,
- boost_hash<int, 17>,
- boost_hash<int, 19> > BoostHashFunctions;
-
- dynamic_bloom_filter<int> bloom1;
- dynamic_bloom_filter<int, BoostHashFunctions> bloom2;
-}
-
-BOOST_AUTO_TEST_CASE(rangeConstructor) {
- int elems[5] = {1,2,3,4,5};
- dynamic_bloom_filter<int> bloom(elems, elems+5);
-
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-BOOST_AUTO_TEST_CASE(copyConstructor) {
- int elems[5] = {1,2,3,4,5};
- dynamic_bloom_filter<int> bloom1(elems, elems+5);
- dynamic_bloom_filter<int> bloom2(bloom1);
-
- BOOST_CHECK_EQUAL(bloom1.count(), bloom2.count());
-}
-
-
-BOOST_AUTO_TEST_CASE(assignment)
-{
- dynamic_bloom_filter<int> bloom1(200);
- dynamic_bloom_filter<int> bloom2(200);
-
- for (size_t i = 0; i < 200; ++i) {
- bloom1.insert(i);
- BOOST_CHECK_EQUAL(bloom1.probably_contains(i), true);
- }
-
- bloom2 = bloom1;
-
- for (size_t i = 0; i < 200; ++i) {
- BOOST_CHECK_EQUAL(bloom2.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(bit_capacity) {
- dynamic_bloom_filter<size_t> bloom_8(8);
- dynamic_bloom_filter<size_t> bloom_256(256);
- dynamic_bloom_filter<size_t> bloom_2048(2048);
-
- BOOST_CHECK_EQUAL(bloom_8.bit_capacity(), 8ul);
- BOOST_CHECK_EQUAL(bloom_256.bit_capacity(), 256ul);
- BOOST_CHECK_EQUAL(bloom_2048.bit_capacity(), 2048ul);
-}
-
-BOOST_AUTO_TEST_CASE(empty) {
- dynamic_bloom_filter<size_t> bloom(8);
-
- BOOST_CHECK_EQUAL(bloom.empty(), true);
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.empty(), false);
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.empty(), true);
-}
-
-BOOST_AUTO_TEST_CASE(numHashFunctions) {
- dynamic_bloom_filter<size_t> bloom_1;
- dynamic_bloom_filter<size_t, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2> > > bloom_2;
- dynamic_bloom_filter<size_t, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2>,
- boost_hash<size_t, 3>,
- boost_hash<size_t, 4>,
- boost_hash<size_t, 5>,
- boost_hash<size_t, 6>,
- boost_hash<size_t, 7> > > bloom_7;
-
- BOOST_CHECK_EQUAL(bloom_1.num_hash_functions(), 1ul);
- BOOST_CHECK_EQUAL(bloom_2.num_hash_functions(), 2ul);
- BOOST_CHECK_EQUAL(bloom_7.num_hash_functions(), 7ul);
-}
-
-BOOST_AUTO_TEST_CASE(falsePositiveRate) {
- dynamic_bloom_filter<size_t> bloom(64);
-
- BOOST_CHECK_EQUAL(bloom.false_positive_rate(), 0.0);
-
- bloom.insert(1);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.015504, .01);
-
- bloom.insert(2);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.030768, .01);
-
- bloom.insert(3);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.045794, .01);
-
- bloom.insert(4);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.060588, .01);
-
- bloom.insert(5);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.075151, .01);
-
- bloom.insert(6);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.089491, .01);
-
- for (size_t i = 7; i < 5000; ++i)
- bloom.insert(i);
-
- BOOST_CHECK_GE(bloom.false_positive_rate(), 0.6);
- BOOST_CHECK_LE(bloom.false_positive_rate(), 1.0);
-}
-
-BOOST_AUTO_TEST_CASE(probably_contains) {
- dynamic_bloom_filter<size_t> bloom(8);
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
- BOOST_CHECK_LE(bloom.count(), 3ul);
- BOOST_CHECK_GE(bloom.count(), 1ul);
-}
-
-BOOST_AUTO_TEST_CASE(doesNotContain) {
- dynamic_bloom_filter<size_t> bloom(8);
-
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
-}
-
-BOOST_AUTO_TEST_CASE(insertNoFalseNegatives) {
- dynamic_bloom_filter<size_t> bloom(2048);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom.insert(i);
- BOOST_CHECK_EQUAL(bloom.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(rangeInsert) {
- int elems[5] = {1,2,3,4,5};
- dynamic_bloom_filter<size_t> bloom(8);
-
- bloom.insert(elems, elems+5);
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-BOOST_AUTO_TEST_CASE(clear) {
- dynamic_bloom_filter<size_t> bloom(8);
-
- for (size_t i = 0; i < 1000; ++i)
- bloom.insert(i);
-
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-struct SwapFixture {
- SwapFixture()
- : bloom1(10), bloom2(20)
- {
- for (size_t i = 0; i < 5; ++i)
- elems[i] = i+1;
-
- bloom1.insert(elems, elems+2);
- bloom2.insert(elems+2, elems+5);
- }
-
- dynamic_bloom_filter<size_t> bloom1;
- dynamic_bloom_filter<size_t> bloom2;
- size_t elems[5];
-};
-
-BOOST_FIXTURE_TEST_CASE(memberSwap, SwapFixture) {
- bloom1.swap(bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom1.bit_capacity(), 20ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
- BOOST_CHECK_EQUAL(bloom2.bit_capacity(), 10ul);
-}
-
-BOOST_FIXTURE_TEST_CASE(globalSwap, SwapFixture) {
- swap(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
-}
-
-struct PairwiseOpsFixture {
- PairwiseOpsFixture() :
- bloom1(100), bloom2(100), bloom_result(100)
- {
- }
-
- dynamic_bloom_filter<size_t> bloom1;
- dynamic_bloom_filter<size_t> bloom2;
- dynamic_bloom_filter<size_t> bloom_result;
-};
-
-BOOST_FIXTURE_TEST_CASE(testUnion, PairwiseOpsFixture) {
- for (size_t i = 0; i < 50; ++i)
- bloom1.insert(i);
-
- for (size_t i = 50; i < 100; ++i)
- bloom2.insert(i);
-
- bloom_result = bloom1 | bloom2;
-
- for (size_t i = 0; i < 100; ++i)
- BOOST_CHECK_EQUAL(bloom_result.probably_contains(i), true);
-
- BOOST_CHECK_GE(bloom_result.count(), bloom1.count());
- BOOST_CHECK_GE(bloom_result.count(), bloom2.count());
-}
-
-BOOST_FIXTURE_TEST_CASE(testUnionAssign, PairwiseOpsFixture) {
- for (size_t i = 0; i < 100; ++i)
- bloom1.insert(i);
-
- bloom_result |= bloom1;
-
- for (size_t i = 0; i < 100; ++i)
- BOOST_CHECK_EQUAL(bloom_result.probably_contains(i), true);
-
- BOOST_CHECK_EQUAL(bloom_result.count(), bloom1.count());
-}
-
-BOOST_FIXTURE_TEST_CASE(testIntersect, PairwiseOpsFixture) {
- // overlap at 50
- for (size_t i = 0; i < 51; ++i)
- bloom1.insert(i);
-
- for (size_t i = 50; i < 100; ++i)
- bloom2.insert(i);
-
- bloom_result = bloom1 & bloom2;
-
- BOOST_CHECK_LE(bloom_result.count(), bloom1.count());
- BOOST_CHECK_LE(bloom_result.count(), bloom2.count());
- BOOST_CHECK_LE(bloom_result.count(), 1ul);
- BOOST_CHECK_EQUAL(bloom_result.probably_contains(50), true);
-}
-
-BOOST_FIXTURE_TEST_CASE(testIntersectAssign, PairwiseOpsFixture) {
- for (size_t i = 0; i < 100; ++i)
- bloom1.insert(i);
-
- bloom_result &= bloom1;
-
- for (size_t i = 0; i < 100; ++i)
- BOOST_CHECK_EQUAL(bloom_result.probably_contains(i), false);
-}
-
-BOOST_FIXTURE_TEST_CASE(equalityOperator, PairwiseOpsFixture) {
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, false);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
-}
-
-BOOST_FIXTURE_TEST_CASE(inequalityOperator, PairwiseOpsFixture) {
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, true);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
-}
-
-struct IncompatibleSizeFixture {
- IncompatibleSizeFixture() :
- bloom1(100), bloom2(101), exception_thrown(false)
- {}
-
- dynamic_bloom_filter<size_t> bloom1;
- dynamic_bloom_filter<size_t> bloom2;
- dynamic_bloom_filter<size_t> bloom3;
- bool exception_thrown;
-};
-
-BOOST_FIXTURE_TEST_CASE(_intersectException, IncompatibleSizeFixture) {
- try {
- bloom3 = bloom1 & bloom2;
- }
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_FIXTURE_TEST_CASE(_unionException, IncompatibleSizeFixture) {
- try {
- bloom3 = bloom1 | bloom2;
- }
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_FIXTURE_TEST_CASE(_equalityException, IncompatibleSizeFixture) {
- try {
- if (bloom1 == bloom2)
- exception_thrown = false;
- }
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_bloom_filter-pass.cpp (from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_bloom-pass.cpp)
==============================================================================

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom-pass.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom-pass.cpp 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
+++ (empty file)
@@ -1,641 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Alejandro Cabrera 2011.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/bloom_filter for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#define BOOST_TEST_DYN_LINK 1
-#define BOOST_TEST_MODULE "Boost Bloom Filter" 1
-
-#include <boost/bloom_filter/dynamic_counting_bloom_filter.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-
-#include <boost/bloom_filter/detail/exceptions.hpp>
-
-#include <boost/cstdint.hpp>
-
-using boost::bloom_filters::dynamic_counting_bloom_filter;
-using boost::bloom_filters::detail::bin_underflow_exception;
-using boost::bloom_filters::detail::bin_overflow_exception;
-using boost::bloom_filters::detail::incompatible_size_exception;
-using boost::bloom_filters::boost_hash;
-
-BOOST_AUTO_TEST_CASE(allBitsPerBinCompile)
-{
- dynamic_counting_bloom_filter<size_t, 1> bloom1;
- dynamic_counting_bloom_filter<size_t, 2> bloom2;
- dynamic_counting_bloom_filter<size_t, 4> bloom4;
- dynamic_counting_bloom_filter<size_t, 8> bloom8;
- dynamic_counting_bloom_filter<size_t, 16> bloom16;
- dynamic_counting_bloom_filter<size_t, 32> bloom32;
-}
-
-BOOST_AUTO_TEST_CASE(allReasonableBlockTypesCompile)
-{
- typedef boost::mpl::vector<boost_hash<int, 0> > default_hash;
-
- dynamic_counting_bloom_filter<int, 2, default_hash, unsigned char> a;
- dynamic_counting_bloom_filter<int, 2, default_hash, unsigned short> b;
- dynamic_counting_bloom_filter<int, 2, default_hash, unsigned int> c;
- dynamic_counting_bloom_filter<int, 2, default_hash, unsigned long> d;
- dynamic_counting_bloom_filter<int, 2, default_hash, size_t> e;
-
- dynamic_counting_bloom_filter<int, 2, default_hash, uint8_t> aa;
- dynamic_counting_bloom_filter<int, 2, default_hash, uint16_t> ab;
- dynamic_counting_bloom_filter<int, 2, default_hash, uint32_t> ac;
- dynamic_counting_bloom_filter<int, 2, default_hash, uintmax_t> ad;
-}
-
-BOOST_AUTO_TEST_CASE(defaultConstructor) {
- typedef boost::mpl::vector<
- boost_hash<int, 13>,
- boost_hash<int, 17>,
- boost_hash<int, 19> > BoostHashFunctions;
-
- dynamic_counting_bloom_filter<int, 2> bloom1;
- dynamic_counting_bloom_filter<int, 2, BoostHashFunctions> bloom2;
- dynamic_counting_bloom_filter<int, 2,
- BoostHashFunctions,
- unsigned char> bloom3;
- dynamic_counting_bloom_filter<int, 2,
- BoostHashFunctions,
- unsigned char,
- std::allocator<unsigned char> > bloom4;
-}
-
-BOOST_AUTO_TEST_CASE(countSingle)
-{
- dynamic_counting_bloom_filter<int> bloom(2);
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.count(), 1ul);
- bloom.remove(1);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(countMulti)
-{
- dynamic_counting_bloom_filter<int> bloom_default(100);
- dynamic_counting_bloom_filter<int, 1> bloom1(100);
- dynamic_counting_bloom_filter<int, 2> bloom2(100);
- dynamic_counting_bloom_filter<int, 8> bloom8(100);
- dynamic_counting_bloom_filter<int, 16> bloom16(100);
- dynamic_counting_bloom_filter<int, 32> bloom32(100);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.insert(i);
- bloom1.insert(i);
- bloom2.insert(i);
- bloom8.insert(i);
- bloom16.insert(i);
- bloom32.insert(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom1.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.insert(i);
- bloom2.insert(i);
- bloom8.insert(i);
- bloom16.insert(i);
- bloom32.insert(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.remove(i);
- bloom2.remove(i);
- bloom8.remove(i);
- bloom16.remove(i);
- bloom32.remove(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom_default.remove(i);
- bloom1.remove(i);
- bloom2.remove(i);
- bloom8.remove(i);
- bloom16.remove(i);
- bloom32.remove(i);
- }
-
- BOOST_CHECK_EQUAL(bloom_default.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom1.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom8.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom16.count(), 0ul);
- BOOST_CHECK_EQUAL(bloom32.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(rangeConstructor) {
- int elems[5] = {1,2,3,4,5};
- dynamic_counting_bloom_filter<int> bloom(elems, elems+5);
-
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-BOOST_AUTO_TEST_CASE(copyConstructor) {
- int elems[5] = {1,2,3,4,5};
- dynamic_counting_bloom_filter<int, 2> bloom1(elems, elems+5);
- dynamic_counting_bloom_filter<int, 2> bloom2(bloom1);
-
- BOOST_CHECK_EQUAL(bloom1.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(assignment)
-{
- dynamic_counting_bloom_filter<int> bloom1(200);
- dynamic_counting_bloom_filter<int> bloom2(200);
-
- for (size_t i = 0; i < 200; ++i) {
- bloom1.insert(i);
- BOOST_CHECK_EQUAL(bloom1.probably_contains(i), true);
- }
-
- bloom2 = bloom1;
-
- for (size_t i = 0; i < 200; ++i) {
- BOOST_CHECK_EQUAL(bloom2.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(bit_capacity) {
- dynamic_counting_bloom_filter<size_t> bloom_8(8);
- dynamic_counting_bloom_filter<size_t> bloom_256(256);
- dynamic_counting_bloom_filter<size_t> bloom_2048(2048);
-
- BOOST_CHECK_EQUAL(bloom_8.bit_capacity(),
- 8ul * bloom_8.bits_per_bin());
- BOOST_CHECK_EQUAL(bloom_256.bit_capacity(),
- 256ul * bloom_256.bits_per_bin());
- BOOST_CHECK_EQUAL(bloom_2048.bit_capacity(),
- 2048ul * bloom_2048.bits_per_bin());
-}
-
-BOOST_AUTO_TEST_CASE(empty) {
- dynamic_counting_bloom_filter<size_t> bloom(2);
-
- BOOST_CHECK_EQUAL(bloom.empty(), true);
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.empty(), false);
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.empty(), true);
-}
-
-BOOST_AUTO_TEST_CASE(numHashFunctions) {
- dynamic_counting_bloom_filter<size_t> bloom_1;
- dynamic_counting_bloom_filter<size_t, 1, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2> > > bloom_2;
- dynamic_counting_bloom_filter<size_t, 1, boost::mpl::vector<
- boost_hash<size_t, 1>,
- boost_hash<size_t, 2>,
- boost_hash<size_t, 3>,
- boost_hash<size_t, 4>,
- boost_hash<size_t, 5>,
- boost_hash<size_t, 6>,
- boost_hash<size_t, 7> > > bloom_7;
-
- BOOST_CHECK_EQUAL(bloom_1.num_hash_functions(), 1ul);
- BOOST_CHECK_EQUAL(bloom_2.num_hash_functions(), 2ul);
- BOOST_CHECK_EQUAL(bloom_7.num_hash_functions(), 7ul);
-}
-
-BOOST_AUTO_TEST_CASE(falsePositiveRate) {
- dynamic_counting_bloom_filter<size_t> bloom(64);
-
- BOOST_CHECK_EQUAL(bloom.false_positive_rate(), 0.0);
-
- bloom.insert(1);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.015504, .01);
-
- bloom.insert(2);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.030768, .01);
-
- bloom.insert(3);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.045794, .01);
-
- bloom.insert(4);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.060588, .01);
-
- bloom.insert(5);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.075151, .01);
-
- bloom.insert(6);
- BOOST_CHECK_CLOSE(bloom.false_positive_rate(), 0.089491, .01);
-
- for (size_t i = 7; i < 128; ++i)
- bloom.insert(i);
-
- BOOST_CHECK_GE(bloom.false_positive_rate(), 0.6);
- BOOST_CHECK_LE(bloom.false_positive_rate(), 1.0);
-}
-
-BOOST_AUTO_TEST_CASE(probably_contains) {
- dynamic_counting_bloom_filter<size_t> bloom(2);
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom.count(), 1ul);
-}
-
-BOOST_AUTO_TEST_CASE(doesNotContain) {
- dynamic_counting_bloom_filter<size_t> bloom(2);
-
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
-}
-
-BOOST_AUTO_TEST_CASE(insertNoFalseNegatives) {
- dynamic_counting_bloom_filter<size_t> bloom(100);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom.insert(i);
- BOOST_CHECK_EQUAL(bloom.probably_contains(i), true);
- }
-}
-
-BOOST_AUTO_TEST_CASE(insertOverflowExceptionThrown) {
- dynamic_counting_bloom_filter<size_t, 1> bloom(2);
- bool exception_occurred = false;
-
- bloom.insert(1);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
-
- try {
- bloom.insert(1);
- }
-
- catch (bin_overflow_exception e) {
- exception_occurred = true;
- }
-
- BOOST_CHECK_EQUAL(exception_occurred, true);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
-}
-
-BOOST_AUTO_TEST_CASE(removeUnderflowExceptionThrown) {
- dynamic_counting_bloom_filter<size_t, 1> bloom(2);
- bool exception_occurred = false;
-
- try {
- bloom.remove(1);
- }
-
- catch (bin_underflow_exception e) {
- exception_occurred = true;
- }
-
- BOOST_CHECK_EQUAL(exception_occurred, true);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
-}
-
-BOOST_AUTO_TEST_CASE(insertOverflowException4bit)
-{
- dynamic_counting_bloom_filter<size_t> bloom(8);
- bool exception_occurred = false;
-
- try {
- for (size_t i = 0; i < (1ul << bloom.bits_per_bin()); ++i)
- bloom.insert(1);
- }
-
- catch (bin_overflow_exception e) {
- exception_occurred = true;
- }
-
- BOOST_CHECK_EQUAL(exception_occurred, true);
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_equality)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- bool exception_thrown = false;
-
- try {
- if (bloom1 == bloom2)
- exception_thrown = false;
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_inequality)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- bool exception_thrown = false;
-
- try {
- if (bloom1 != bloom2)
- exception_thrown = false;
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_union)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- dynamic_counting_bloom_filter<int> bloom_result;
- bool exception_thrown = false;
-
- try {
- bloom_result = experimental_union(bloom1, bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_intersect)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- dynamic_counting_bloom_filter<int> bloom_result;
- bool exception_thrown = false;
-
- try {
- bloom_result = experimental_intersect(bloom1, bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_unionAssign)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- bool exception_thrown = false;
-
- try {
- bloom1.experimental_union_assign(bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_intersectAssign)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- bool exception_thrown = false;
-
- try {
- bloom1.experimental_intersect_assign(bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(rangeInsert) {
- int elems[5] = {1,2,3,4,5};
- dynamic_counting_bloom_filter<size_t> bloom(5);
-
- bloom.insert(elems, elems+5);
- BOOST_CHECK_EQUAL(bloom.count(), 5ul);
-}
-
-BOOST_AUTO_TEST_CASE(_remove) {
- dynamic_counting_bloom_filter<size_t> bloom(1);
-
- bloom.insert(1);
- bloom.remove(1);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(removeMulti) {
- dynamic_counting_bloom_filter<size_t> bloom(100);
-
- for (size_t i = 0; i < 100; ++i) {
- bloom.insert(i);
- bloom.remove(i);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
- }
-}
-
-BOOST_AUTO_TEST_CASE(rangeRemove) {
- size_t arr[] = {1,2,3,4,5};
- dynamic_counting_bloom_filter<size_t> bloom(5);
-
- bloom.insert(arr, arr+5);
- bloom.remove(arr, arr+5);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-BOOST_AUTO_TEST_CASE(clear) {
- dynamic_counting_bloom_filter<size_t> bloom(100);
-
- for (size_t i = 0; i < 100; ++i)
- bloom.insert(i);
-
- bloom.clear();
- BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom.count(), 0ul);
-}
-
-struct SwapFixture {
- SwapFixture()
- : bloom1(5), bloom2(5)
- {
- for (size_t i = 0; i < 5; ++i)
- elems[i] = i+1;
-
- bloom1.insert(elems, elems+2);
- bloom2.insert(elems+2, elems+5);
- }
-
- size_t elems[5];
- dynamic_counting_bloom_filter<size_t> bloom1;
- dynamic_counting_bloom_filter<size_t> bloom2;
-};
-
-BOOST_FIXTURE_TEST_CASE(memberSwap, SwapFixture) {
- bloom1.swap(bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
-}
-
-BOOST_FIXTURE_TEST_CASE(globalSwap, SwapFixture) {
- swap(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
- BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
-}
-
-struct PairwiseOpsFixture {
-
- PairwiseOpsFixture()
- : bloom1(300), bloom2(300), bloom_result(300)
- {}
-
- dynamic_counting_bloom_filter<size_t> bloom1;
- dynamic_counting_bloom_filter<size_t> bloom2;
- dynamic_counting_bloom_filter<size_t> bloom_result;
-};
-
-BOOST_AUTO_TEST_CASE(testUnion) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom2(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_union(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_union = experimental_union(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_GE(bloom_union.count(), bloom1.count());
- BOOST_CHECK_GE(bloom_union.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testUnionAssign) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_union(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
-
- bloom_union.insert(1);
- bloom_union.insert(3);
- bloom_union.insert(3);
-
- bloom_union.experimental_union_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_union.count(), 3ul);
-}
-
-BOOST_AUTO_TEST_CASE(testIntersect) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom2(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_intersect(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_intersect = experimental_intersect(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_LE(bloom_intersect.count(), bloom1.count());
- BOOST_CHECK_LE(bloom_intersect.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testIntersectAssign) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_intersect(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
-
- bloom1.insert(0);
- bloom1.insert(0);
- bloom_intersect.insert(1);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
-
- bloom_intersect.experimental_intersect_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_intersect.count(), 2ul);
-}
-
-BOOST_FIXTURE_TEST_CASE(equalityOperator, PairwiseOpsFixture) {
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, false);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
-}
-
-BOOST_FIXTURE_TEST_CASE(inequalityOperator, PairwiseOpsFixture) {
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
- bloom1.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, true);
- bloom2.insert(1);
- BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
-}

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom_filter-pass.cpp (from r73661, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom-pass.cpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom-pass.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/dynamic_counting_bloom_filter-pass.cpp 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
@@ -366,76 +366,6 @@
   BOOST_CHECK_EQUAL(exception_thrown, true);
 }
 
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_union)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- dynamic_counting_bloom_filter<int> bloom_result;
- bool exception_thrown = false;
-
- try {
- bloom_result = experimental_union(bloom1, bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_intersect)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- dynamic_counting_bloom_filter<int> bloom_result;
- bool exception_thrown = false;
-
- try {
- bloom_result = experimental_intersect(bloom1, bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_unionAssign)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- bool exception_thrown = false;
-
- try {
- bloom1.experimental_union_assign(bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
-BOOST_AUTO_TEST_CASE(incompatibleSizeExceptionThrown_intersectAssign)
-{
- dynamic_counting_bloom_filter<int> bloom1(1);
- dynamic_counting_bloom_filter<int> bloom2(2);
- bool exception_thrown = false;
-
- try {
- bloom1.experimental_intersect_assign(bloom2);
- }
-
- catch (incompatible_size_exception e) {
- exception_thrown = true;
- }
-
- BOOST_CHECK_EQUAL(exception_thrown, true);
-}
-
 BOOST_AUTO_TEST_CASE(rangeInsert) {
   int elems[5] = {1,2,3,4,5};
   dynamic_counting_bloom_filter<size_t> bloom(5);
@@ -523,107 +453,6 @@
   dynamic_counting_bloom_filter<size_t> bloom_result;
 };
 
-BOOST_AUTO_TEST_CASE(testUnion) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom2(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_union(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_union = experimental_union(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_GE(bloom_union.count(), bloom1.count());
- BOOST_CHECK_GE(bloom_union.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testUnionAssign) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_union(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(1);
-
- bloom_union.insert(1);
- bloom_union.insert(3);
- bloom_union.insert(3);
-
- bloom_union.experimental_union_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(0), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_union.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_union.count(), 3ul);
-}
-
-BOOST_AUTO_TEST_CASE(testIntersect) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom2(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_intersect(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
- bloom1.insert(3);
-
- bloom2.insert(0);
- bloom2.insert(0);
- bloom2.insert(1);
- bloom2.insert(1);
- bloom2.insert(3);
- bloom2.insert(3);
-
- bloom_intersect = experimental_intersect(bloom1, bloom2);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_LE(bloom_intersect.count(), bloom1.count());
- BOOST_CHECK_LE(bloom_intersect.count(), bloom2.count());
-}
-
-BOOST_AUTO_TEST_CASE(testIntersectAssign) {
- dynamic_counting_bloom_filter<size_t, 2> bloom1(4);
- dynamic_counting_bloom_filter<size_t, 2> bloom_intersect(4);
-
- bloom1.insert(0);
- bloom1.insert(1);
- bloom1.insert(3);
-
- bloom1.insert(0);
- bloom1.insert(0);
- bloom_intersect.insert(1);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
- bloom_intersect.insert(3);
-
- bloom_intersect.experimental_intersect_assign(bloom1);
-
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(0), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(1), true);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(2), false);
- BOOST_CHECK_EQUAL(bloom_intersect.probably_contains(3), true);
- BOOST_CHECK_EQUAL(bloom_intersect.count(), 2ul);
-}
-
 BOOST_FIXTURE_TEST_CASE(equalityOperator, PairwiseOpsFixture) {
   BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
   bloom1.insert(1);

Added: sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_dynamic_counting_bloom_filter-pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/twohash_dynamic_counting_bloom_filter-pass.cpp 2011-08-13 01:10:24 EDT (Sat, 13 Aug 2011)
@@ -0,0 +1,423 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Alejandro Cabrera 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/bloom_filter for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#define BOOST_TEST_DYN_LINK 1
+#define BOOST_TEST_MODULE "Boost Bloom Filter" 1
+
+#include <boost/bloom_filter/twohash_dynamic_counting_bloom_filter.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+
+#include <boost/bloom_filter/detail/exceptions.hpp>
+
+#include <boost/cstdint.hpp>
+
+using boost::bloom_filters::twohash_dynamic_counting_bloom_filter;
+using boost::bloom_filters::detail::bin_underflow_exception;
+using boost::bloom_filters::detail::bin_overflow_exception;
+using boost::bloom_filters::detail::incompatible_size_exception;
+using boost::bloom_filters::boost_hash;
+using boost::bloom_filters::murmurhash3;
+using boost::bloom_filters::detail::zero;
+
+BOOST_AUTO_TEST_CASE(allBitsPerBinCompile)
+{
+ twohash_dynamic_counting_bloom_filter<size_t, 1> bloom1;
+ twohash_dynamic_counting_bloom_filter<size_t, 2> bloom2;
+ twohash_dynamic_counting_bloom_filter<size_t, 4> bloom4;
+ twohash_dynamic_counting_bloom_filter<size_t, 8> bloom8;
+ twohash_dynamic_counting_bloom_filter<size_t, 16> bloom16;
+ twohash_dynamic_counting_bloom_filter<size_t, 32> bloom32;
+}
+
+BOOST_AUTO_TEST_CASE(allReasonableBlockTypesCompile)
+{
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, unsigned char> a;
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, unsigned short> b;
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, unsigned int> c;
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, unsigned long> d;
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, size_t> e;
+
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, uint8_t> aa;
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, uint16_t> ab;
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, uint32_t> ac;
+ twohash_dynamic_counting_bloom_filter<int, 2, 4, 0,
+ boost_hash<int, 0>, murmurhash3<int>,
+ zero, uintmax_t> ad;
+}
+
+BOOST_AUTO_TEST_CASE(defaultConstructor) {
+ twohash_dynamic_counting_bloom_filter<int> bloom_default;
+ twohash_dynamic_counting_bloom_filter<int, 1> bloom_1bit_per_bin;
+ twohash_dynamic_counting_bloom_filter<int, 2, 1,
+ 9> bloom_9expected_insertions;
+ twohash_dynamic_counting_bloom_filter<int, 2, 1, 9,
+ boost_hash<int, 0> > bloom_remixed_hash;
+ twohash_dynamic_counting_bloom_filter<int, 2, 1, 9,
+ boost_hash<int, 0>,
+ murmurhash3<int> > bloom_very_remixed_hash;
+ twohash_dynamic_counting_bloom_filter<int, 2, 1, 9,
+ boost_hash<int, 0>,
+ murmurhash3<int>,
+ zero> bloom_very_reconfigured;
+ twohash_dynamic_counting_bloom_filter<int, 2, 1, 9,
+ boost_hash<int, 0>,
+ murmurhash3<int>,
+ zero, uint8_t> bloom_fully_reconfigured;
+}
+
+BOOST_AUTO_TEST_CASE(countSingle)
+{
+ twohash_dynamic_counting_bloom_filter<int, 4, 1> bloom;
+
+ bloom.insert(1);
+ BOOST_CHECK_EQUAL(bloom.count(), 1ul);
+ bloom.remove(1);
+ BOOST_CHECK_EQUAL(bloom.count(), 0ul);
+}
+
+BOOST_AUTO_TEST_CASE(countMulti)
+{
+ twohash_dynamic_counting_bloom_filter<int, 4, 1> bloom_default(400);
+ twohash_dynamic_counting_bloom_filter<int, 1, 1> bloom1(400);
+ twohash_dynamic_counting_bloom_filter<int, 2, 1> bloom2(400);
+ twohash_dynamic_counting_bloom_filter<int, 4, 1> bloom4(400);
+ twohash_dynamic_counting_bloom_filter<int, 8, 1> bloom8(400);
+ twohash_dynamic_counting_bloom_filter<int, 16, 1> bloom16(400);
+ twohash_dynamic_counting_bloom_filter<int, 32, 1> bloom32(400);
+
+ for (size_t i = 0; i < 100; ++i) {
+ bloom_default.insert(i);
+ bloom1.insert(i);
+ bloom2.insert(i);
+ bloom4.insert(i);
+ bloom8.insert(i);
+ bloom16.insert(i);
+ bloom32.insert(i);
+ }
+
+ BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom1.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom4.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
+
+ for (size_t i = 0; i < 100; ++i) {
+ bloom_default.insert(i);
+ bloom2.insert(i);
+ bloom4.insert(i);
+ bloom8.insert(i);
+ bloom16.insert(i);
+ bloom32.insert(i);
+ }
+
+ BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom4.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
+
+ for (size_t i = 0; i < 100; ++i) {
+ bloom_default.remove(i);
+ bloom2.remove(i);
+ bloom4.remove(i);
+ bloom8.remove(i);
+ bloom16.remove(i);
+ bloom32.remove(i);
+ }
+
+ BOOST_CHECK_EQUAL(bloom_default.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom2.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom4.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom8.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom16.count(), 100ul);
+ BOOST_CHECK_EQUAL(bloom32.count(), 100ul);
+
+ for (size_t i = 0; i < 100; ++i) {
+ bloom_default.remove(i);
+ bloom1.remove(i);
+ bloom2.remove(i);
+ bloom4.remove(i);
+ bloom8.remove(i);
+ bloom16.remove(i);
+ bloom32.remove(i);
+ }
+
+ BOOST_CHECK_EQUAL(bloom_default.count(), 0ul);
+ BOOST_CHECK_EQUAL(bloom1.count(), 0ul);
+ BOOST_CHECK_EQUAL(bloom2.count(), 0ul);
+ BOOST_CHECK_EQUAL(bloom4.count(), 0ul);
+ BOOST_CHECK_EQUAL(bloom8.count(), 0ul);
+ BOOST_CHECK_EQUAL(bloom16.count(), 0ul);
+ BOOST_CHECK_EQUAL(bloom32.count(), 0ul);
+}
+
+BOOST_AUTO_TEST_CASE(rangeConstructor) {
+ int elems[5] = {1,2,3,4,5};
+ twohash_dynamic_counting_bloom_filter<int, 4, 1> bloom(elems, elems+5);
+
+ BOOST_CHECK_EQUAL(bloom.count(), 5ul);
+}
+
+BOOST_AUTO_TEST_CASE(copyConstructor) {
+ int elems[5] = {1,2,3,4,5};
+ twohash_dynamic_counting_bloom_filter<int> bloom1(elems, elems+5);
+ twohash_dynamic_counting_bloom_filter<int> bloom2(bloom1);
+
+ BOOST_CHECK_EQUAL(bloom1.count(), bloom2.count());
+}
+
+BOOST_AUTO_TEST_CASE(assignment)
+{
+ twohash_dynamic_counting_bloom_filter<int> bloom1(200);
+ twohash_dynamic_counting_bloom_filter<int> bloom2(200);
+
+ for (size_t i = 0; i < 200; ++i) {
+ bloom1.insert(i);
+ BOOST_CHECK_EQUAL(bloom1.probably_contains(i), true);
+ }
+
+ bloom2 = bloom1;
+
+ for (size_t i = 0; i < 200; ++i) {
+ BOOST_CHECK_EQUAL(bloom2.probably_contains(i), true);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(bit_capacity) {
+ twohash_dynamic_counting_bloom_filter<size_t> bloom_8(8);
+ twohash_dynamic_counting_bloom_filter<size_t> bloom_256(256);
+ twohash_dynamic_counting_bloom_filter<size_t> bloom_2048(2048);
+
+ BOOST_CHECK_EQUAL(bloom_8.bit_capacity(),
+ 8ul * bloom_8.bits_per_bin());
+ BOOST_CHECK_EQUAL(bloom_256.bit_capacity(),
+ 256ul * bloom_256.bits_per_bin());
+ BOOST_CHECK_EQUAL(bloom_2048.bit_capacity(),
+ 2048ul * bloom_2048.bits_per_bin());
+}
+
+BOOST_AUTO_TEST_CASE(empty) {
+ twohash_dynamic_counting_bloom_filter<size_t> bloom;
+
+ BOOST_CHECK_EQUAL(bloom.empty(), true);
+ bloom.insert(1);
+ BOOST_CHECK_EQUAL(bloom.empty(), false);
+ bloom.clear();
+ BOOST_CHECK_EQUAL(bloom.empty(), true);
+}
+
+BOOST_AUTO_TEST_CASE(numHashFunctions) {
+ twohash_dynamic_counting_bloom_filter<int, 2> bloom_2h;
+ twohash_dynamic_counting_bloom_filter<int, 2, 1> bloom_1h;
+ twohash_dynamic_counting_bloom_filter<int, 2, 7> bloom_7h;
+
+ BOOST_CHECK_EQUAL(bloom_1h.num_hash_functions(), 1ul);
+ BOOST_CHECK_EQUAL(bloom_2h.num_hash_functions(), 2ul);
+ BOOST_CHECK_EQUAL(bloom_7h.num_hash_functions(), 7ul);
+}
+
+BOOST_AUTO_TEST_CASE(probably_contains) {
+ twohash_dynamic_counting_bloom_filter<size_t, 4, 1> bloom;
+
+ bloom.insert(1);
+ BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
+ BOOST_CHECK_EQUAL(bloom.count(), 1ul);
+}
+
+BOOST_AUTO_TEST_CASE(doesNotContain) {
+ twohash_dynamic_counting_bloom_filter<size_t> bloom;
+
+ BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
+}
+
+BOOST_AUTO_TEST_CASE(insertNoFalseNegatives) {
+ twohash_dynamic_counting_bloom_filter<size_t> bloom(100);
+
+ for (size_t i = 0; i < 100; ++i) {
+ bloom.insert(i);
+ BOOST_CHECK_EQUAL(bloom.probably_contains(i), true);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(insertOverflowExceptionThrown) {
+ twohash_dynamic_counting_bloom_filter<size_t, 1> bloom;
+ bool exception_occurred = false;
+
+ bloom.insert(1);
+ BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
+
+ try {
+ bloom.insert(1);
+ }
+
+ catch (bin_overflow_exception e) {
+ exception_occurred = true;
+ }
+
+ BOOST_CHECK_EQUAL(exception_occurred, true);
+ BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
+}
+
+BOOST_AUTO_TEST_CASE(removeUnderflowExceptionThrown) {
+ twohash_dynamic_counting_bloom_filter<size_t, 1> bloom;
+ bool exception_occurred = false;
+
+ try {
+ bloom.remove(1);
+ }
+
+ catch (bin_underflow_exception e) {
+ exception_occurred = true;
+ }
+
+ BOOST_CHECK_EQUAL(exception_occurred, true);
+ BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
+}
+
+BOOST_AUTO_TEST_CASE(insertOverflowException4bit)
+{
+ twohash_dynamic_counting_bloom_filter<size_t, 4> bloom;
+ bool exception_occurred = false;
+
+ try {
+ for (size_t i = 0; i < (1ul << bloom.bits_per_bin()); ++i)
+ bloom.insert(1);
+ }
+
+ catch (bin_overflow_exception e) {
+ exception_occurred = true;
+ }
+
+ BOOST_CHECK_EQUAL(exception_occurred, true);
+ BOOST_CHECK_EQUAL(bloom.probably_contains(1), true);
+}
+
+BOOST_AUTO_TEST_CASE(rangeInsert) {
+ int elems[5] = {1,2,3,4,5};
+ twohash_dynamic_counting_bloom_filter<size_t> bloom(10);
+
+ bloom.insert(elems, elems+5);
+ BOOST_CHECK_EQUAL(bloom.count(), 5ul);
+}
+
+BOOST_AUTO_TEST_CASE(_remove) {
+ twohash_dynamic_counting_bloom_filter<size_t> bloom;
+
+ bloom.insert(1);
+ bloom.remove(1);
+ BOOST_CHECK_EQUAL(bloom.count(), 0ul);
+}
+
+BOOST_AUTO_TEST_CASE(removeMulti) {
+ twohash_dynamic_counting_bloom_filter<size_t> bloom(100);
+
+ for (size_t i = 0; i < 100; ++i) {
+ bloom.insert(i);
+ bloom.remove(i);
+ BOOST_CHECK_EQUAL(bloom.count(), 0ul);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(rangeRemove) {
+ size_t arr[] = {1,2,3,4,5};
+ twohash_dynamic_counting_bloom_filter<size_t> bloom;
+
+ bloom.insert(arr, arr+5);
+ bloom.remove(arr, arr+5);
+ BOOST_CHECK_EQUAL(bloom.count(), 0ul);
+}
+
+BOOST_AUTO_TEST_CASE(clear) {
+ twohash_dynamic_counting_bloom_filter<size_t> bloom(1000);
+
+ for (size_t i = 0; i < 1000; ++i)
+ bloom.insert(i);
+
+ bloom.clear();
+ BOOST_CHECK_EQUAL(bloom.probably_contains(1), false);
+ BOOST_CHECK_EQUAL(bloom.count(), 0ul);
+}
+
+struct SwapFixture {
+ SwapFixture()
+ : bloom1(5), bloom2(5)
+ {
+ for (size_t i = 0; i < 5; ++i)
+ elems[i] = i+1;
+
+ bloom1.insert(elems, elems+2);
+ bloom2.insert(elems+2, elems+5);
+ }
+
+ size_t elems[5];
+ twohash_dynamic_counting_bloom_filter<size_t, 4, 1> bloom1;
+ twohash_dynamic_counting_bloom_filter<size_t, 4, 1> bloom2;
+};
+
+BOOST_FIXTURE_TEST_CASE(memberSwap, SwapFixture) {
+ bloom1.swap(bloom2);
+
+ BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
+ BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
+}
+
+BOOST_FIXTURE_TEST_CASE(globalSwap, SwapFixture) {
+ swap(bloom1, bloom2);
+
+ BOOST_CHECK_EQUAL(bloom1.count(), 3ul);
+ BOOST_CHECK_EQUAL(bloom2.count(), 2ul);
+}
+
+struct PairwiseOpsFixture {
+
+ PairwiseOpsFixture() {}
+
+ twohash_dynamic_counting_bloom_filter<size_t> bloom1;
+ twohash_dynamic_counting_bloom_filter<size_t> bloom2;
+ twohash_dynamic_counting_bloom_filter<size_t> bloom_result;
+};
+
+BOOST_FIXTURE_TEST_CASE(equalityOperator, PairwiseOpsFixture) {
+ BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
+ bloom1.insert(1);
+ BOOST_CHECK_EQUAL(bloom1 == bloom2, false);
+ bloom2.insert(1);
+ BOOST_CHECK_EQUAL(bloom1 == bloom2, true);
+}
+
+BOOST_FIXTURE_TEST_CASE(inequalityOperator, PairwiseOpsFixture) {
+ BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
+ bloom1.insert(1);
+ BOOST_CHECK_EQUAL(bloom1 != bloom2, true);
+ bloom2.insert(1);
+ BOOST_CHECK_EQUAL(bloom1 != bloom2, false);
+}


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