BPHash
General object hashing library for C++
test_unique.cpp
Go to the documentation of this file.
1 #include "test_helpers.hpp"
2 
3 #include <algorithm>
4 
5 
6 using namespace bphash;
7 
8 
9 // In test_integers.cpp
10 void test_integers(HashType htype, std::vector<HashValue> & all_hashes);
11 
12 // In test_floating.cpp
13 void test_floating(HashType htype, std::vector<HashValue> & all_hashes);
14 
15 // In test_string.cpp
16 void test_string(HashType htype, std::vector<HashValue> & all_hashes);
17 
18 // In test_tuple.cpp
19 void test_tuple(HashType htype, std::vector<HashValue> & all_hashes);
20 
21 
22 int main(void)
23 {
24  // A vector containing all the computed hashes
25  std::vector<HashValue> all_hashes;
26 
27  test_integers(HashType::Hash128, all_hashes);
28  test_floating(HashType::Hash128, all_hashes);
29  test_string(HashType::Hash128, all_hashes);
30  test_tuple(HashType::Hash128, all_hashes);
31 
32  std::cout << "\n";
33  std::cout << "==============================================================================\n";
34  std::cout << "Created " << all_hashes.size() << " hashes.\n";
35  std::sort(all_hashes.begin(), all_hashes.end());
36 
37  auto dup = std::adjacent_find(all_hashes.begin(), all_hashes.end());
38  if(dup != all_hashes.end())
39  {
40  std::cout << "DUPLICATE FOUND: " << hash_to_string(*dup) << "\n";
41  return 1;
42  }
43  else
44  std::cout << "No duplicates found. Hooray!\n";
45 
46 
47  return 0;
48 }
49 
void test_floating(HashType htype, std::vector< HashValue > &all_hashes)
void test_integers(HashType htype, std::vector< HashValue > &all_hashes)
void test_tuple(HashType htype, std::vector< HashValue > &all_hashes)
Definition: test_tuple.cpp:14
Helper functions for testing.
std::string hash_to_string(const HashValue &hash)
Return a string representation of a hash.
Definition: Hash.cpp:17
void test_string(HashType htype, std::vector< HashValue > &all_hashes)
Definition: test_string.cpp:14
HashType
Type of hash to use.
Definition: Hasher.hpp:25
int main(void)
Definition: test_unique.cpp:22
Default 128-bit hash.