|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
68 void Check (
const std::string hashName,
const uint32_t
hash);
74 void Check (
const std::string hashName,
const uint64_t
hash);
87 void Check (
const std::string hashName,
const int bits,
const uint64_t
hash);
88 virtual void DoRun (
void);
94 key (
"The quick brown fox jumped over the lazy dogs.")
132 std::cout <<
GetName () <<
"checking "
134 << bits <<
"-bit result...";
136 hashName <<
" " << type
137 <<
" produced " << std::hex << std::setw (w) <<
hash
138 <<
", expected " << std::hex << std::setw (w) << hashRef
141 std::cout << std::hex << std::setw (w) <<
hash <<
", ok"
142 << std::dec << std::endl;
163 virtual void DoRun (
void);
176 std::cout <<
GetName () <<
"checking with key: \""
177 <<
key <<
"\"" << std::endl;
199 virtual void DoRun (
void);
212 Hasher hasher =
Hasher ( Create<Hash::Function::Fnv1a> () );
234 virtual void DoRun (
void);
247 Hasher hasher =
Hasher ( Create<Hash::Function::Murmur3> () );
270 gnu_sum (
const char * buffer,
const std::size_t size)
272 const char * p = buffer;
273 const char *
const pend = p + size;
275 uint16_t checksum = 0;
279 checksum = (checksum >> 1) + ((checksum & 1) << 15);
293 uint32_t h =
gnu_sum (buffer, size);
294 return (uint32_t)( (h << 16) + h);
306 return (uint64_t)( (h << 32) + h);
322 virtual void DoRun (
void);
353 virtual void DoRun (
void);
384 virtual void DoRun (
void);
418 key1 =
"The quick brown ";
419 key2 =
"Incremental.";
422 std::cout <<
GetName () <<
"checking with key: "
423 <<
"\"" <<
key1 <<
"\"[" <<
key1.size () <<
"] + "
424 <<
"\"" <<
key2 <<
"\"[" <<
key2.size () <<
"]" << std::endl;
425 std::cout <<
GetName () <<
"equivalent to: "
426 <<
"\"" <<
key12 <<
"\"[" <<
key12.size () <<
"]" << std::endl;
429 DoHash (
"murmur3",
Hasher ( Create<Hash::Function::Murmur3> () ) );
430 DoHash (
"FNV1a",
Hasher ( Create<Hash::Function::Fnv1a> () ) );
uint32_t gnu_sum32(const char *buffer, const std::size_t size)
A 32-bit hash function, based on gnu_sum().
Fnv1aTestCase()
Constructor.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual void DoRun(void)
Implementation to actually run this TestCase.
HashTestSuite()
Constructor.
virtual ~DefaultHashTestCase()
Destructor.
static HashTestSuite g_hashTestSuite
HashTestSuite instance variable.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Test 32-bit function pointer.
HashTestCase(const std::string name)
Constructor.
std::string GetName(void) const
virtual ~Hash32FunctionPtrTestCase()
Destructor.
uint32_t hash32Reference
The 32-bit hash of the reference.
virtual ~IncrementalTestCase()
Destructor.
uint64_t gnu_sum64(const char *buffer, const std::size_t size)
A 64-bit hash function, base on gnu_sum().
std::string key2
test string
void Check(const std::string hashName, const uint32_t hash)
Check function.
uint64_t GetHash64(const char *buffer, const std::size_t size)
Compute 64-bit hash of a byte buffer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint64_t Hash64(const char *buffer, const std::size_t size)
Compute 64-bit hash of a byte buffer, using the default hash function.
std::string key1
test string
Generic Hash function interface.
virtual ~HashTestCase()
Destructor.
Test default hash on fixed string.
Murmur3TestCase()
Constructor.
Hash functions test suite.
uint32_t Hash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer, using the default hash function.
uint16_t gnu_sum(const char *buffer, const std::size_t size)
Simple hash function based on the GNU sum program.
virtual ~Fnv1aTestCase()
Destructor.
Test incremental hashing.
Test Murmur3 hash on fixed string.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
DefaultHashTestCase()
Constructor.
Hash32FunctionPtrTestCase()
Constructor.
Hasher & clear(void)
Restore initial state.
virtual ~Hash64FunctionPtrTestCase()
Destructor.
uint64_t hash64Reference
The 64-bit hash of the reference.
IncrementalTestCase()
Constructor.
void DoHash(const std::string name, Hasher hasher)
Complute the hash test function.
Test 64-bit function pointer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
FNV hash on fixed string.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Hash64FunctionPtrTestCase()
Constructor.
std::string key12
test string
Base class for hash tests.
virtual ~Murmur3TestCase()
Destructor.
std::string key
The reference value to hash.
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.