38 void Check (
const std::string hashName,
const uint32_t hash);
39 void Check (
const std::string hashName,
const uint64_t hash);
44 void Check (
const std::string hashName,
const int bits,
const uint64_t hash);
45 virtual void DoRun (
void);
50 key (
"The quick brown fox jumped over the lazy dogs.")
61 Check (hashName, 32, hash);
67 Check (hashName, 64, hash);
90 std::cout <<
GetName () <<
"checking "
92 << bits <<
"-bit result...";
94 hashName <<
" " << type
95 <<
" produced " << std::hex << std::setw (w) << hash
96 <<
", expected " << std::hex << std::setw (w) << hashRef
99 std::cout << std::hex << std::setw (w) << hash <<
", ok"
100 << std::dec << std::endl;
119 virtual void DoRun (
void);
134 std::cout <<
GetName () <<
"checking with key: \""
135 <<
key <<
"\"" << std::endl;
154 virtual void DoRun (
void);
169 Hasher hasher =
Hasher ( Create<Hash::Function::Fnv1a> () );
188 virtual void DoRun (
void);
203 Hasher hasher =
Hasher ( Create<Hash::Function::Murmur3> () );
221 gnu_sum (
const char * buffer,
const size_t size)
223 const char * p = buffer;
224 const char *
const pend = p + size;
226 uint16_t checksum = 0;
230 checksum = (checksum >> 1) + ((checksum & 1) << 15);
240 uint32_t h =
gnu_sum (buffer, size);
241 return (uint32_t)( (h << 16) + h);
249 return (uint64_t)( (h << 32) + h);
261 virtual void DoRun (
void);
290 virtual void DoRun (
void);
319 virtual void DoRun (
void);
351 key1 =
"The quick brown ";
352 key2 =
"Incremental.";
355 std::cout <<
GetName () <<
"checking with key: "
356 <<
"\"" <<
key1 <<
"\"[" <<
key1.size () <<
"] + "
357 <<
"\"" << key2 <<
"\"[" << key2.size () <<
"]" << std::endl;
358 std::cout <<
GetName () <<
"equivalent to: "
359 <<
"\"" <<
key12 <<
"\"[" <<
key12.size () <<
"]" << std::endl;
362 DoHash (
"murmur3",
Hasher ( Create<Hash::Function::Murmur3> () ) );
363 DoHash (
"FNV1a",
Hasher ( Create<Hash::Function::Fnv1a> () ) );
virtual ~DefaultHashTestCase()
Test 64-bit function pointer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void DoHash(const std::string name, Hasher hasher)
Test incremental hashing.
virtual ~IncrementalTestCase()
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Base class for hash tests.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t gnu_sum32(const char *buffer, const size_t size)
uint32_t GetHash32(const char *buffer, const size_t size)
Compute 32-bit hash of a byte buffer.
uint32_t Hash32(const char *buffer, const size_t size)
Compute 32-bit hash of a byte buffer, using the default hash function.
static HashTestSuite g_hashTestSuite
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint16_t gnu_sum(const char *buffer, const size_t size)
Hasher & clear(void)
Restore initial state.
virtual ~Hash32FunctionPtrTestCase()
Hash64FunctionPtrTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test 32-bit function pointer.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
virtual ~Murmur3TestCase()
uint64_t Hash64(const char *buffer, const size_t size)
Compute 64-bit hash of a byte buffer, using the default hash function.
void Check(const std::string hashName, const uint32_t hash)
Hash32FunctionPtrTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::string GetName(void) const
uint64_t GetHash64(const char *buffer, const size_t size)
Compute 64-bit hash of a byte buffer.
HashTestCase(const std::string name)
uint64_t gnu_sum64(const char *buffer, const size_t size)
Hash functions test suite.
virtual ~Hash64FunctionPtrTestCase()
Generic Hash function interface.