63 void Check(
const std::string hashName,
const uint64_t hash);
76 void Check(
const std::string hashName,
const int bits,
const uint64_t hash);
77 void DoRun()
override;
83 key(
"The quick brown fox jumped over the lazy dogs.")
94 Check(hashName, 32, hash);
100 Check(hashName, 64, hash);
123 std::cout <<
GetName() <<
"checking " << hashName <<
" " << bits <<
"-bit result...";
126 hashName <<
" " << type <<
" produced " << std::hex << std::setw(w)
127 << hash <<
", expected " << std::hex << std::setw(w) << hashRef
129 std::cout << std::hex << std::setw(w) << hash <<
", ok" << std::dec << std::endl;
150 void DoRun()
override;
165 std::cout <<
GetName() <<
"checking with key: \"" <<
key <<
"\"" << std::endl;
187 void DoRun()
override;
223 void DoRun()
override;
260gnu_sum(
const char* buffer,
const std::size_t size)
262 const char* p = buffer;
263 const char*
const pend = p + size;
265 uint16_t checksum = 0;
269 checksum = (checksum >> 1) + ((checksum & 1) << 15);
296 return (uint64_t)((h << 32) + h);
312 void DoRun()
override;
345 void DoRun()
override;
378 void DoRun()
override;
414 key1 =
"The quick brown ";
415 key2 =
"Incremental.";
418 std::cout <<
GetName() <<
"checking with key: "
419 <<
"\"" <<
key1 <<
"\"[" <<
key1.size() <<
"] + "
420 <<
"\"" <<
key2 <<
"\"[" <<
key2.size() <<
"]" << std::endl;
421 std::cout <<
GetName() <<
"equivalent to: "
422 <<
"\"" <<
key12 <<
"\"[" <<
key12.size() <<
"]" << std::endl;
Generic Hash function interface.
uint32_t GetHash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer.
uint64_t GetHash64(const char *buffer, const std::size_t size)
Compute 64-bit hash of a byte buffer.
Hasher & clear()
Restore initial state.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
std::string GetName() const
Test default hash on fixed string.
DefaultHashTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
~DefaultHashTestCase() override
Destructor.
FNV hash on fixed string.
void DoRun() override
Implementation to actually run this TestCase.
Fnv1aTestCase()
Constructor.
~Fnv1aTestCase() override
Destructor.
Test 32-bit function pointer.
Hash32FunctionPtrTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
~Hash32FunctionPtrTestCase() override
Destructor.
Test 64-bit function pointer.
Hash64FunctionPtrTestCase()
Constructor.
~Hash64FunctionPtrTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
Base class for hash tests.
void DoRun() override
Implementation to actually run this TestCase.
uint64_t hash64Reference
The 64-bit hash of the reference.
uint32_t hash32Reference
The 32-bit hash of the reference.
~HashTestCase() override
Destructor.
HashTestCase(const std::string name)
Constructor.
std::string key
The reference value to hash.
void Check(const std::string hashName, const uint32_t hash)
Check function.
Hash functions test suite.
HashTestSuite()
Constructor.
Test incremental hashing.
std::string key1
test string
void DoRun() override
Implementation to actually run this TestCase.
~IncrementalTestCase() override
Destructor.
void DoHash(const std::string name, Hasher hasher)
Complute the hash test function.
std::string key2
test string
IncrementalTestCase()
Constructor.
std::string key12
test string
Test Murmur3 hash on fixed string.
void DoRun() override
Implementation to actually run this TestCase.
Murmur3TestCase()
Constructor.
~Murmur3TestCase() override
Destructor.
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().
static HashTestSuite g_hashTestSuite
HashTestSuite instance variable.
uint16_t gnu_sum(const char *buffer, const std::size_t size)
Simple hash function based on the GNU sum program.
uint64_t Hash64(const char *buffer, const std::size_t size)
Compute 64-bit hash of a byte buffer, using the default hash function.
uint32_t Hash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer, using the default hash function.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.