Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
hash_fct_test.cc File Reference

Tests for Hash Fct. More...

#include <gtest/gtest.h>
#include <hash-fct.H>
#include <array>
#include <cstring>
#include <random>
#include <set>
#include <string>
#include <vector>
Include dependency graph for hash_fct_test.cc:

Go to the source code of this file.

Classes

class  HashTestEnvironment
 
class  HashConsistencyTest
 
class  HashEdgeCaseTest
 
class  HashDifferenceTest
 
class  HashVoidPtrTest
 
class  HashTemplateTest
 
struct  UserTypeNS::Point3D
 
class  HashDistributionTest
 
class  HashAvalancheTest
 

Namespaces

namespace  UserTypeNS
 

Functions

 TEST_F (HashConsistencyTest, AddHashConsistency)
 
 TEST_F (HashConsistencyTest, XorHashConsistency)
 
 TEST_F (HashConsistencyTest, RotHashConsistency)
 
 TEST_F (HashConsistencyTest, DjbHashConsistency)
 
 TEST_F (HashConsistencyTest, SaxHashConsistency)
 
 TEST_F (HashConsistencyTest, FnvHashConsistency)
 
 TEST_F (HashConsistencyTest, OatHashConsistency)
 
 TEST_F (HashConsistencyTest, JswHashConsistency)
 
 TEST_F (HashConsistencyTest, ElfHashConsistency)
 
 TEST_F (HashConsistencyTest, JenHashConsistency)
 
 TEST_F (HashConsistencyTest, SuperFastHashConsistency)
 
 TEST_F (HashConsistencyTest, Murmur3HashConsistency)
 
 TEST_F (HashConsistencyTest, DftHashFctConsistency)
 
 TEST_F (HashConsistencyTest, DftHashUsesWyhashBackend)
 
 TEST_F (HashConsistencyTest, XxHash64Consistency)
 
 TEST_F (HashConsistencyTest, WyHashConsistency)
 
 TEST_F (HashConsistencyTest, SipHashConsistency)
 
 TEST_F (HashEdgeCaseTest, EmptyStringHash)
 
 TEST_F (HashEdgeCaseTest, SingleCharHash)
 
 TEST_F (HashEdgeCaseTest, LargeStringHash)
 
 TEST_F (HashEdgeCaseTest, BinaryDataWithNulls)
 
 TEST_F (HashDifferenceTest, DifferentStringsDifferentHashes)
 
 TEST_F (HashDifferenceTest, DifferentIntsDifferentHashes)
 
 TEST_F (HashDifferenceTest, DifferentSeedsDifferentHashes)
 
 TEST_F (HashVoidPtrTest, IntArrayHash)
 
 TEST_F (HashVoidPtrTest, StructHash)
 
 TEST_F (HashTemplateTest, IntTemplateHash)
 
 TEST_F (HashTemplateTest, DoubleTemplateHash)
 
 TEST_F (HashTemplateTest, LongLongTemplateHash)
 
 TEST (PairHashTest, PairDftHashFct)
 
 TEST (PairHashTest, PairSndHashFct)
 
 TEST (PairHashTest, MixedPairComponents)
 
 TEST (PairHashTest, PointerWrappersMatchDirectCalls)
 
size_t UserTypeNS::aleph_hash_value (const Point3D &p) noexcept
 
 TEST (AlephHashADL, UserTypeDeterministic)
 
 TEST (AlephHashADL, UserTypeDftAndSndDiffer)
 
 TEST (AlephHashADL, UserTypeDistinctPointsDistinctHashes)
 
 TEST (AlephHashADL, ConceptDetectedCorrectly)
 
 TEST_F (HashDistributionTest, FnvHashUniqueness)
 
 TEST_F (HashDistributionTest, OatHashUniqueness)
 
 TEST_F (HashDistributionTest, SuperFastHashUniqueness)
 
 TEST_F (HashDistributionTest, JenHashUniqueness)
 
 TEST_F (HashDistributionTest, Murmur3HashUniqueness)
 
 TEST_F (HashDistributionTest, DftHashFctUniqueness)
 
 TEST_F (HashDistributionTest, XxHash64Uniqueness)
 
 TEST_F (HashDistributionTest, WyHashUniqueness)
 
 TEST_F (HashDistributionTest, SipHashUniqueness)
 
 TEST_F (HashAvalancheTest, SingleBitChangeJenkins)
 
 TEST_F (HashAvalancheTest, SingleBitChangeMurmur3)
 
 TEST_F (HashAvalancheTest, SingleBitChangeXxHash64)
 
 TEST_F (HashAvalancheTest, SingleBitChangeWyHash)
 
 TEST_F (HashAvalancheTest, SingleBitChangeSipHash)
 
 TEST_F (HashAvalancheTest, SingleBitChangeOat)
 
 TEST (HashKnownValuesTest, AddHashKnownValue)
 
 TEST (HashKnownValuesTest, XorHashKnownValue)
 
 TEST (HashKnownValuesTest, FnvHashStartValue)
 
 TEST (HashKnownValuesTest, SipHashOfficialVectors)
 
 TEST (SeededHashTest, JenHashWithDefaultSeed)
 
 TEST (SeededHashTest, DftHashFctWithSeed)
 
 TEST (HashTypeSafetyTest, SignedUnsignedConsistency)
 
 TEST (HashTypeSafetyTest, ConstCharPtrAndStringConsistency)
 
 TEST (HashTypeSafetyTest, PointerHashIsStableAcrossCallPaths)
 
 TEST (HashPerformanceTest, LargeDataHashing)
 
 TEST (HashPerformanceTest, ManySmallHashes)
 

Variables

testing::Environment *const hash_env
 

Detailed Description

Tests for Hash Fct.

Exhaustive test suite for hash functions in hash-fct.H.

Tests cover:

  • Consistency: same input always produces same output
  • Various input types: void*, templates, const char*, std::string
  • Edge cases: empty strings, single byte, large data
  • Basic distribution quality (collision rates)
  • All hash functions: add_hash, xor_hash, rot_hash, djb_hash, sax_hash, fnv_hash, oat_hash, jsw_hash, elf_hash, jen_hash, SuperFastHash, murmur3hash, dft_hash_fct, snd_hash_fct

Definition in file hash_fct_test.cc.

Function Documentation

◆ TEST() [1/19]

TEST ( AlephHashADL  ,
ConceptDetectedCorrectly   
)

Definition at line 693 of file hash_fct_test.cc.

◆ TEST() [2/19]

TEST ( AlephHashADL  ,
UserTypeDeterministic   
)

Definition at line 669 of file hash_fct_test.cc.

References Aleph::dft_hash_fct(), and Aleph::snd_hash_fct().

◆ TEST() [3/19]

TEST ( AlephHashADL  ,
UserTypeDftAndSndDiffer   
)

Definition at line 678 of file hash_fct_test.cc.

References Aleph::dft_hash_fct(), and Aleph::snd_hash_fct().

◆ TEST() [4/19]

TEST ( AlephHashADL  ,
UserTypeDistinctPointsDistinctHashes   
)

Definition at line 685 of file hash_fct_test.cc.

References Aleph::dft_hash_fct().

◆ TEST() [5/19]

TEST ( HashKnownValuesTest  ,
AddHashKnownValue   
)

Definition at line 949 of file hash_fct_test.cc.

References Aleph::add_hash().

◆ TEST() [6/19]

TEST ( HashKnownValuesTest  ,
FnvHashStartValue   
)

Definition at line 961 of file hash_fct_test.cc.

References Aleph::fnv_hash().

◆ TEST() [7/19]

TEST ( HashKnownValuesTest  ,
SipHashOfficialVectors   
)

Definition at line 969 of file hash_fct_test.cc.

References Aleph::siphash24_hash().

◆ TEST() [8/19]

TEST ( HashKnownValuesTest  ,
XorHashKnownValue   
)

Definition at line 955 of file hash_fct_test.cc.

References Aleph::xor_hash().

◆ TEST() [9/19]

TEST ( HashPerformanceTest  ,
LargeDataHashing   
)

◆ TEST() [10/19]

TEST ( HashPerformanceTest  ,
ManySmallHashes   
)

Definition at line 1084 of file hash_fct_test.cc.

References Aleph::fnv_hash(), and Aleph::sum().

◆ TEST() [11/19]

TEST ( HashTypeSafetyTest  ,
ConstCharPtrAndStringConsistency   
)

◆ TEST() [12/19]

TEST ( HashTypeSafetyTest  ,
PointerHashIsStableAcrossCallPaths   
)

◆ TEST() [13/19]

TEST ( HashTypeSafetyTest  ,
SignedUnsignedConsistency   
)

Definition at line 1018 of file hash_fct_test.cc.

References Aleph::fnv_hash().

◆ TEST() [14/19]

TEST ( PairHashTest  ,
MixedPairComponents   
)

Definition at line 623 of file hash_fct_test.cc.

References Aleph::pair_dft_hash_fct(), and Aleph::pair_snd_hash_fct().

◆ TEST() [15/19]

TEST ( PairHashTest  ,
PairDftHashFct   
)

Definition at line 597 of file hash_fct_test.cc.

References Aleph::pair_dft_hash_fct().

◆ TEST() [16/19]

TEST ( PairHashTest  ,
PairSndHashFct   
)

Definition at line 612 of file hash_fct_test.cc.

References Aleph::pair_snd_hash_fct().

◆ TEST() [17/19]

TEST ( PairHashTest  ,
PointerWrappersMatchDirectCalls   
)

Definition at line 632 of file hash_fct_test.cc.

References Aleph::pair_dft_hash_fct(), and Aleph::pair_snd_hash_fct().

◆ TEST() [18/19]

TEST ( SeededHashTest  ,
DftHashFctWithSeed   
)

Definition at line 1006 of file hash_fct_test.cc.

References Aleph::dft_hash_fct().

◆ TEST() [19/19]

TEST ( SeededHashTest  ,
JenHashWithDefaultSeed   
)

Definition at line 998 of file hash_fct_test.cc.

References Aleph::Default_Hash_Seed, and Aleph::jen_hash().

◆ TEST_F() [1/44]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeJenkins   
)

Definition at line 859 of file hash_fct_test.cc.

References Aleph::jen_hash().

◆ TEST_F() [2/44]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeMurmur3   
)

Definition at line 876 of file hash_fct_test.cc.

References Aleph::murmur3hash().

◆ TEST_F() [3/44]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeOat   
)

Definition at line 932 of file hash_fct_test.cc.

References Aleph::oat_hash().

◆ TEST_F() [4/44]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeSipHash   
)

Definition at line 918 of file hash_fct_test.cc.

References Aleph::siphash24_hash().

◆ TEST_F() [5/44]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeWyHash   
)

Definition at line 904 of file hash_fct_test.cc.

References Aleph::wyhash_hash().

◆ TEST_F() [6/44]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeXxHash64   
)

Definition at line 890 of file hash_fct_test.cc.

References Aleph::xxhash64_hash().

◆ TEST_F() [7/44]

TEST_F ( HashConsistencyTest  ,
AddHashConsistency   
)

Definition at line 89 of file hash_fct_test.cc.

References Aleph::add_hash().

◆ TEST_F() [8/44]

TEST_F ( HashConsistencyTest  ,
DftHashFctConsistency   
)

Definition at line 263 of file hash_fct_test.cc.

References Aleph::dft_hash_fct().

◆ TEST_F() [9/44]

TEST_F ( HashConsistencyTest  ,
DftHashUsesWyhashBackend   
)

◆ TEST_F() [10/44]

TEST_F ( HashConsistencyTest  ,
DjbHashConsistency   
)

Definition at line 135 of file hash_fct_test.cc.

References Aleph::djb_hash().

◆ TEST_F() [11/44]

TEST_F ( HashConsistencyTest  ,
ElfHashConsistency   
)

Definition at line 205 of file hash_fct_test.cc.

References Aleph::elf_hash().

◆ TEST_F() [12/44]

TEST_F ( HashConsistencyTest  ,
FnvHashConsistency   
)

Definition at line 163 of file hash_fct_test.cc.

References Aleph::fnv_hash().

◆ TEST_F() [13/44]

TEST_F ( HashConsistencyTest  ,
JenHashConsistency   
)

Definition at line 219 of file hash_fct_test.cc.

References Aleph::jen_hash(), and seed.

◆ TEST_F() [14/44]

TEST_F ( HashConsistencyTest  ,
JswHashConsistency   
)

Definition at line 191 of file hash_fct_test.cc.

References Aleph::jsw_hash().

◆ TEST_F() [15/44]

TEST_F ( HashConsistencyTest  ,
Murmur3HashConsistency   
)

Definition at line 251 of file hash_fct_test.cc.

References Aleph::murmur3hash(), and seed.

◆ TEST_F() [16/44]

TEST_F ( HashConsistencyTest  ,
OatHashConsistency   
)

Definition at line 177 of file hash_fct_test.cc.

References Aleph::oat_hash().

◆ TEST_F() [17/44]

TEST_F ( HashConsistencyTest  ,
RotHashConsistency   
)

Definition at line 121 of file hash_fct_test.cc.

References Aleph::rot_hash().

◆ TEST_F() [18/44]

TEST_F ( HashConsistencyTest  ,
SaxHashConsistency   
)

Definition at line 149 of file hash_fct_test.cc.

References Aleph::sax_hash().

◆ TEST_F() [19/44]

TEST_F ( HashConsistencyTest  ,
SipHashConsistency   
)

Definition at line 313 of file hash_fct_test.cc.

References Aleph::siphash24_hash().

◆ TEST_F() [20/44]

TEST_F ( HashConsistencyTest  ,
SuperFastHashConsistency   
)

Definition at line 237 of file hash_fct_test.cc.

References Aleph::SuperFastHash().

◆ TEST_F() [21/44]

TEST_F ( HashConsistencyTest  ,
WyHashConsistency   
)

Definition at line 299 of file hash_fct_test.cc.

References Aleph::wyhash_hash().

◆ TEST_F() [22/44]

TEST_F ( HashConsistencyTest  ,
XorHashConsistency   
)

Definition at line 105 of file hash_fct_test.cc.

References Aleph::xor_hash().

◆ TEST_F() [23/44]

TEST_F ( HashConsistencyTest  ,
XxHash64Consistency   
)

Definition at line 285 of file hash_fct_test.cc.

References Aleph::xxhash64_hash().

◆ TEST_F() [24/44]

TEST_F ( HashDifferenceTest  ,
DifferentIntsDifferentHashes   
)

◆ TEST_F() [25/44]

TEST_F ( HashDifferenceTest  ,
DifferentSeedsDifferentHashes   
)

◆ TEST_F() [26/44]

TEST_F ( HashDifferenceTest  ,
DifferentStringsDifferentHashes   
)

◆ TEST_F() [27/44]

TEST_F ( HashDistributionTest  ,
DftHashFctUniqueness   
)

Definition at line 795 of file hash_fct_test.cc.

References Aleph::dft_hash_fct(), and keys.

◆ TEST_F() [28/44]

TEST_F ( HashDistributionTest  ,
FnvHashUniqueness   
)

Definition at line 740 of file hash_fct_test.cc.

References Aleph::fnv_hash(), and keys.

◆ TEST_F() [29/44]

TEST_F ( HashDistributionTest  ,
JenHashUniqueness   
)

Definition at line 773 of file hash_fct_test.cc.

References Aleph::jen_hash(), and keys.

◆ TEST_F() [30/44]

TEST_F ( HashDistributionTest  ,
Murmur3HashUniqueness   
)

Definition at line 784 of file hash_fct_test.cc.

References keys, and Aleph::murmur3hash().

◆ TEST_F() [31/44]

TEST_F ( HashDistributionTest  ,
OatHashUniqueness   
)

Definition at line 751 of file hash_fct_test.cc.

References keys, and Aleph::oat_hash().

◆ TEST_F() [32/44]

TEST_F ( HashDistributionTest  ,
SipHashUniqueness   
)

Definition at line 828 of file hash_fct_test.cc.

References keys, and Aleph::siphash24_hash().

◆ TEST_F() [33/44]

TEST_F ( HashDistributionTest  ,
SuperFastHashUniqueness   
)

Definition at line 762 of file hash_fct_test.cc.

References keys, and Aleph::SuperFastHash().

◆ TEST_F() [34/44]

TEST_F ( HashDistributionTest  ,
WyHashUniqueness   
)

Definition at line 817 of file hash_fct_test.cc.

References keys, and Aleph::wyhash_hash().

◆ TEST_F() [35/44]

TEST_F ( HashDistributionTest  ,
XxHash64Uniqueness   
)

Definition at line 806 of file hash_fct_test.cc.

References keys, and Aleph::xxhash64_hash().

◆ TEST_F() [36/44]

TEST_F ( HashEdgeCaseTest  ,
BinaryDataWithNulls   
)

◆ TEST_F() [37/44]

◆ TEST_F() [38/44]

◆ TEST_F() [39/44]

◆ TEST_F() [40/44]

TEST_F ( HashTemplateTest  ,
DoubleTemplateHash   
)

Definition at line 569 of file hash_fct_test.cc.

References Aleph::fnv_hash(), and Aleph::oat_hash().

◆ TEST_F() [41/44]

TEST_F ( HashTemplateTest  ,
IntTemplateHash   
)

Definition at line 555 of file hash_fct_test.cc.

References Aleph::add_hash(), and Aleph::fnv_hash().

◆ TEST_F() [42/44]

TEST_F ( HashTemplateTest  ,
LongLongTemplateHash   
)

Definition at line 582 of file hash_fct_test.cc.

References Aleph::fnv_hash(), and Aleph::SuperFastHash().

◆ TEST_F() [43/44]

◆ TEST_F() [44/44]

TEST_F ( HashVoidPtrTest  ,
StructHash   
)

Definition at line 523 of file hash_fct_test.cc.

References Aleph::fnv_hash(), Aleph::oat_hash(), and Aleph::SuperFastHash().

Variable Documentation

◆ hash_env

testing::Environment* const hash_env
Initial value:
=
testing::AddGlobalTestEnvironment(new HashTestEnvironment)

Definition at line 74 of file hash_fct_test.cc.