@@ -79,8 +79,9 @@ TEST_CASE("bloom_filter: standard constructors", "[bloom_filter]") {
79
79
TEST_CASE (" bloom_filter: basic operations" , " [bloom_filter]" ) {
80
80
uint64_t num_items = 5000 ;
81
81
double fpp = 0.01 ;
82
+ uint64_t seed = 4897301548054ULL ;
82
83
83
- auto bf = bloom_filter::builder::create_by_accuracy (num_items, fpp);
84
+ auto bf = bloom_filter::builder::create_by_accuracy (num_items, fpp, seed );
84
85
REQUIRE (bf.is_empty ());
85
86
REQUIRE (bf.get_bits_used () == 0 );
86
87
@@ -90,16 +91,20 @@ TEST_CASE("bloom_filter: basic operations", "[bloom_filter]") {
90
91
91
92
REQUIRE (!bf.is_empty ());
92
93
// filter is about 50% full at target capacity
93
- REQUIRE (bf.get_bits_used () == Approx (0.5 * bf.get_capacity ()).epsilon (0.05 ));
94
+ // since seed is fixed we expect an exact value every time
95
+ // but leaving the approximate test in since that's more the "expectation"
96
+ REQUIRE (bf.get_bits_used () == 24793 ); // exact value is not important but should be consistent
97
+ REQUIRE (bf.get_bits_used () == Approx (0.5 * bf.get_capacity ()).epsilon (0.05 )); // just over 3.3% in practice
94
98
95
99
uint32_t num_found = 0 ;
96
100
for (uint64_t i = num_items; i < bf.get_capacity (); ++i) {
97
101
if (bf.query (i)) {
98
102
++num_found;
99
103
}
100
104
}
101
- // fpp is average with significant variance
102
- REQUIRE (num_found == Approx ((bf.get_capacity () - num_items) * fpp).epsilon (0.12 ));
105
+ // fpp is average with significant variance -- even at 12% it would fail occasionally
106
+ REQUIRE (num_found == 423 );
107
+ // REQUIRE(num_found == Approx((bf.get_capacity() - num_items) * fpp).epsilon(0.12));
103
108
auto bytes = bf.serialize ();
104
109
105
110
// initialize in memory and run the same tests
0 commit comments