Aleph-w 3.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 <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
 
class  HashDistributionTest
 
class  HashAvalancheTest
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Functions

void Aleph::init_jsw () noexcept
 
 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 (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_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 (HashAvalancheTest, SingleBitChangeJenkins)
 
 TEST_F (HashAvalancheTest, SingleBitChangeMurmur3)
 
 TEST_F (HashAvalancheTest, SingleBitChangeOat)
 
 TEST (HashKnownValuesTest, AddHashKnownValue)
 
 TEST (HashKnownValuesTest, XorHashKnownValue)
 
 TEST (HashKnownValuesTest, FnvHashStartValue)
 
 TEST (SeededHashTest, JenHashWithDefaultSeed)
 
 TEST (SeededHashTest, DftHashFctWithSeed)
 
 TEST (HashTypeSafetyTest, SignedUnsignedConsistency)
 
 TEST (HashTypeSafetyTest, ConstCharPtrAndStringConsistency)
 
 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/11]

TEST ( HashKnownValuesTest  ,
AddHashKnownValue   
)

Definition at line 722 of file hash_fct_test.cc.

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

◆ TEST() [2/11]

TEST ( HashKnownValuesTest  ,
FnvHashStartValue   
)

Definition at line 734 of file hash_fct_test.cc.

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

◆ TEST() [3/11]

TEST ( HashKnownValuesTest  ,
XorHashKnownValue   
)

Definition at line 728 of file hash_fct_test.cc.

References Aleph::maps(), and Aleph::xor_hash().

◆ TEST() [4/11]

TEST ( HashPerformanceTest  ,
LargeDataHashing   
)

◆ TEST() [5/11]

TEST ( HashPerformanceTest  ,
ManySmallHashes   
)

Definition at line 811 of file hash_fct_test.cc.

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

◆ TEST() [6/11]

TEST ( HashTypeSafetyTest  ,
ConstCharPtrAndStringConsistency   
)

◆ TEST() [7/11]

TEST ( HashTypeSafetyTest  ,
SignedUnsignedConsistency   
)

Definition at line 764 of file hash_fct_test.cc.

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

◆ TEST() [8/11]

TEST ( PairHashTest  ,
PairDftHashFct   
)

Definition at line 524 of file hash_fct_test.cc.

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

◆ TEST() [9/11]

TEST ( PairHashTest  ,
PairSndHashFct   
)

Definition at line 540 of file hash_fct_test.cc.

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

◆ TEST() [10/11]

TEST ( SeededHashTest  ,
DftHashFctWithSeed   
)

Definition at line 752 of file hash_fct_test.cc.

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

◆ TEST() [11/11]

TEST ( SeededHashTest  ,
JenHashWithDefaultSeed   
)

Definition at line 744 of file hash_fct_test.cc.

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

◆ TEST_F() [1/34]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeJenkins   
)

Definition at line 674 of file hash_fct_test.cc.

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

◆ TEST_F() [2/34]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeMurmur3   
)

Definition at line 691 of file hash_fct_test.cc.

References Aleph::maps(), and Aleph::murmur3hash().

◆ TEST_F() [3/34]

TEST_F ( HashAvalancheTest  ,
SingleBitChangeOat   
)

Definition at line 705 of file hash_fct_test.cc.

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

◆ TEST_F() [4/34]

TEST_F ( HashConsistencyTest  ,
AddHashConsistency   
)

Definition at line 93 of file hash_fct_test.cc.

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

◆ TEST_F() [5/34]

TEST_F ( HashConsistencyTest  ,
DftHashFctConsistency   
)

Definition at line 267 of file hash_fct_test.cc.

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

◆ TEST_F() [6/34]

TEST_F ( HashConsistencyTest  ,
DjbHashConsistency   
)

Definition at line 139 of file hash_fct_test.cc.

References Aleph::djb_hash(), and Aleph::maps().

◆ TEST_F() [7/34]

TEST_F ( HashConsistencyTest  ,
ElfHashConsistency   
)

Definition at line 209 of file hash_fct_test.cc.

References Aleph::elf_hash(), and Aleph::maps().

◆ TEST_F() [8/34]

TEST_F ( HashConsistencyTest  ,
FnvHashConsistency   
)

Definition at line 167 of file hash_fct_test.cc.

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

◆ TEST_F() [9/34]

TEST_F ( HashConsistencyTest  ,
JenHashConsistency   
)

Definition at line 223 of file hash_fct_test.cc.

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

◆ TEST_F() [10/34]

TEST_F ( HashConsistencyTest  ,
JswHashConsistency   
)

Definition at line 195 of file hash_fct_test.cc.

References Aleph::jsw_hash(), and Aleph::maps().

◆ TEST_F() [11/34]

TEST_F ( HashConsistencyTest  ,
Murmur3HashConsistency   
)

Definition at line 255 of file hash_fct_test.cc.

References Aleph::maps(), and Aleph::murmur3hash().

◆ TEST_F() [12/34]

TEST_F ( HashConsistencyTest  ,
OatHashConsistency   
)

Definition at line 181 of file hash_fct_test.cc.

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

◆ TEST_F() [13/34]

TEST_F ( HashConsistencyTest  ,
RotHashConsistency   
)

Definition at line 125 of file hash_fct_test.cc.

References Aleph::maps(), and Aleph::rot_hash().

◆ TEST_F() [14/34]

TEST_F ( HashConsistencyTest  ,
SaxHashConsistency   
)

Definition at line 153 of file hash_fct_test.cc.

References Aleph::maps(), and Aleph::sax_hash().

◆ TEST_F() [15/34]

TEST_F ( HashConsistencyTest  ,
SuperFastHashConsistency   
)

Definition at line 241 of file hash_fct_test.cc.

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

◆ TEST_F() [16/34]

TEST_F ( HashConsistencyTest  ,
XorHashConsistency   
)

Definition at line 109 of file hash_fct_test.cc.

References Aleph::maps(), and Aleph::xor_hash().

◆ TEST_F() [17/34]

TEST_F ( HashDifferenceTest  ,
DifferentIntsDifferentHashes   
)

◆ TEST_F() [18/34]

TEST_F ( HashDifferenceTest  ,
DifferentSeedsDifferentHashes   
)

Definition at line 405 of file hash_fct_test.cc.

References Aleph::jen_hash(), Aleph::maps(), and Aleph::murmur3hash().

◆ TEST_F() [19/34]

◆ TEST_F() [20/34]

TEST_F ( HashDistributionTest  ,
DftHashFctUniqueness   
)

Definition at line 643 of file hash_fct_test.cc.

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

◆ TEST_F() [21/34]

TEST_F ( HashDistributionTest  ,
FnvHashUniqueness   
)

Definition at line 588 of file hash_fct_test.cc.

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

◆ TEST_F() [22/34]

TEST_F ( HashDistributionTest  ,
JenHashUniqueness   
)

Definition at line 621 of file hash_fct_test.cc.

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

◆ TEST_F() [23/34]

TEST_F ( HashDistributionTest  ,
Murmur3HashUniqueness   
)

Definition at line 632 of file hash_fct_test.cc.

References Aleph::maps(), and Aleph::murmur3hash().

◆ TEST_F() [24/34]

TEST_F ( HashDistributionTest  ,
OatHashUniqueness   
)

Definition at line 599 of file hash_fct_test.cc.

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

◆ TEST_F() [25/34]

TEST_F ( HashDistributionTest  ,
SuperFastHashUniqueness   
)

Definition at line 610 of file hash_fct_test.cc.

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

◆ TEST_F() [26/34]

TEST_F ( HashEdgeCaseTest  ,
BinaryDataWithNulls   
)

◆ TEST_F() [27/34]

◆ TEST_F() [28/34]

TEST_F ( HashEdgeCaseTest  ,
LargeStringHash   
)

◆ TEST_F() [29/34]

◆ TEST_F() [30/34]

TEST_F ( HashTemplateTest  ,
DoubleTemplateHash   
)

Definition at line 496 of file hash_fct_test.cc.

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

◆ TEST_F() [31/34]

TEST_F ( HashTemplateTest  ,
IntTemplateHash   
)

Definition at line 482 of file hash_fct_test.cc.

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

◆ TEST_F() [32/34]

TEST_F ( HashTemplateTest  ,
LongLongTemplateHash   
)

Definition at line 509 of file hash_fct_test.cc.

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

◆ TEST_F() [33/34]

◆ TEST_F() [34/34]

TEST_F ( HashVoidPtrTest  ,
StructHash   
)

Variable Documentation

◆ hash_env

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

Definition at line 78 of file hash_fct_test.cc.