67 void Check (
const std::string hashName,
const uint32_t hash);
73 void Check (
const std::string hashName,
const uint64_t hash);
86 void Check (
const std::string hashName,
const int bits,
const uint64_t hash);
87 virtual void DoRun (
void);
93 key (
"The quick brown fox jumped over the lazy dogs.")
104 Check (hashName, 32, hash);
110 Check (hashName, 64, hash);
133 std::cout <<
GetName () <<
"checking " 135 << bits <<
"-bit result...";
137 hashName <<
" " << type
138 <<
" produced " << std::hex << std::setw (w) << hash
139 <<
", expected " << std::hex << std::setw (w) << hashRef
142 std::cout << std::hex << std::setw (w) << hash <<
", ok" 143 << std::dec << std::endl;
164 virtual void DoRun (
void);
179 std::cout <<
GetName () <<
"checking with key: \"" 180 <<
key <<
"\"" << std::endl;
201 virtual void DoRun (
void);
216 Hasher hasher =
Hasher ( Create<Hash::Function::Fnv1a> () );
237 virtual void DoRun (
void);
252 Hasher hasher =
Hasher ( Create<Hash::Function::Murmur3> () );
275 gnu_sum (
const char * buffer,
const std::size_t size)
277 const char * p = buffer;
278 const char *
const pend = p + size;
280 uint16_t checksum = 0;
284 checksum = (checksum >> 1) + ((checksum & 1) << 15);
298 uint32_t h =
gnu_sum (buffer, size);
299 return (uint32_t)( (h << 16) + h);
311 return (uint64_t)( (h << 32) + h);
326 virtual void DoRun (
void);
358 virtual void DoRun (
void);
390 virtual void DoRun (
void);
426 key1 =
"The quick brown ";
427 key2 =
"Incremental.";
430 std::cout <<
GetName () <<
"checking with key: " 431 <<
"\"" <<
key1 <<
"\"[" <<
key1.size () <<
"] + " 432 <<
"\"" <<
key2 <<
"\"[" <<
key2.size () <<
"]" << std::endl;
433 std::cout <<
GetName () <<
"equivalent to: " 434 <<
"\"" <<
key12 <<
"\"[" <<
key12.size () <<
"]" << std::endl;
437 DoHash (
"murmur3",
Hasher ( Create<Hash::Function::Murmur3> () ) );
438 DoHash (
"FNV1a",
Hasher ( Create<Hash::Function::Fnv1a> () ) );
virtual ~Hash64FunctionPtrTestCase()
Destructor.
Test incremental hashing.
uint32_t GetHash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Fnv1aTestCase()
Constructor.
virtual ~Hash32FunctionPtrTestCase()
Destructor.
#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.
Hash64FunctionPtrTestCase()
Constructor.
uint32_t gnu_sum32(const char *buffer, const std::size_t size)
A 32-bit hash function, based on gnu_sum().
uint64_t gnu_sum64(const char *buffer, const std::size_t size)
A 64-bit hash function, base on gnu_sum().
virtual ~HashTestCase()
Destructor.
Test 64-bit function pointer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::string key1
test string
virtual ~IncrementalTestCase()
Destructor.
uint64_t hash64Reference
The 64-bit hash of the reference.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
FNV hash on fixed string.
std::string key2
test string
static HashTestSuite g_hashTestSuite
HashTestSuite instance variable.
uint64_t Hash64(const char *buffer, const std::size_t size)
Compute 64-bit hash of a byte buffer, using the default hash function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::string key12
test string
virtual ~DefaultHashTestCase()
Destructor.
Hasher & clear(void)
Restore initial state.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t Hash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer, using the default hash function.
virtual ~Murmur3TestCase()
Destructor.
uint16_t gnu_sum(const char *buffer, const std::size_t size)
Simple hash function based on the GNU sum program.
uint64_t GetHash64(const char *buffer, const std::size_t size)
Compute 64-bit hash of a byte buffer.
DefaultHashTestCase()
Constructor.
HashTestSuite()
Constructor.
IncrementalTestCase()
Constructor.
HashTestCase(const std::string name)
Constructor.
Hash32FunctionPtrTestCase()
Constructor.
std::string key
The reference value to hash.
std::string GetName(void) const
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t hash32Reference
The 32-bit hash of the reference.
Test default hash on fixed string.
Test 32-bit function pointer.
Test Murmur3 hash on fixed string.
Murmur3TestCase()
Constructor.
void DoHash(const std::string name, Hasher hasher)
Complute the hash test function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Generic Hash function interface.
virtual ~Fnv1aTestCase()
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void Check(const std::string hashName, const uint32_t hash)
Check function.
Hash functions test suite.