22 #include <boost/test/unit_test.hpp> 65 int const m = f.
size * 8;
66 int const k = BitsPerBloom;
68 double singleBitSet = 1.0 / m;
69 double singleBitNotSet = (1.0 - singleBitSet);
72 for (
int i = 0; i < k * n; ++i)
73 singleNot *= singleBitNotSet;
75 double single = 1.0 - singleNot;
78 for (
int i = 0; i < k; ++i)
86 int const c_sampleSize = 1000;
87 int falsePositive = 0;
89 for (
int i = 0; i < c_sampleSize; ++i)
97 double res = double(falsePositive) / double(c_sampleSize);
100 double allowed = expected * 1.2 + 0.05;
103 BOOST_REQUIRE(res <= allowed);
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
void removeRaw(FixedHash< N > const &_h)
void testAddNonExisting(TopicBloomFilterShort &_f, AbridgedTopic const &_h)
std::hash for asio::adress
BOOST_AUTO_TEST_CASE(dummyTest)
bool containsRaw(FixedHash< N > const &_h) const
void testRemoveExistingBloom(TopicBloomFilterShort &_f, AbridgedTopic const &_h)
double testFalsePositiveRate(TopicBloomFilterTest const &f, int inserted, Topic &x)
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
void removeBloom(AbridgedTopic const &_h)
double calculateExpected(TopicBloomFilterTest const &f, int n)
void addBloom(AbridgedTopic const &_h)
void addRaw(FixedHash< N > const &_h)
#define BOOST_FIXTURE_TEST_SUITE(a, b)
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
#define BOOST_AUTO_TEST_SUITE_END()
bool containsBloom(AbridgedTopic const &_h) const
void testRemoveExisting(TopicBloomFilterShort &_f, AbridgedTopic const &_h)
void testAddNonExistingBloom(TopicBloomFilterShort &_f, AbridgedTopic const &_h)
Helper functions to work with json::spirit and test files.