30 #include <gtest/gtest.h>
34 #include <unordered_map>
42 TEST(HashHelpers, isHashEnabled)
44 EXPECT_TRUE(stl_helpers::is_hash_enabled<int>);
45 EXPECT_TRUE(stl_helpers::is_hash_enabled<long>);
46 EXPECT_TRUE(stl_helpers::is_hash_enabled<double>);
47 EXPECT_TRUE(stl_helpers::is_hash_enabled<std::string>);
48 EXPECT_TRUE(stl_helpers::is_hash_enabled<void*>);
50 EXPECT_TRUE(stl_helpers::is_hash_enabled<vector_t>);
51 using tuple_t = std::tuple<int, bool,
int**, std::string(*)(float)>;
52 EXPECT_TRUE(stl_helpers::is_hash_enabled<tuple_t>);
55 std::unordered_map<tuple_t, vector_t>>));
63 TEST(HashHelpers, hashPair)
65 auto p = std::make_pair(1, std::string(
"hello"));
67 auto hashFunc = stl_helpers::hash<std::pair<int, std::string>>{};
68 EXPECT_EQ(hashVal, hashFunc(
p));
71 TEST(HashHelpers, hashTuple)
73 auto t = std::make_tuple(1,
"hello", 4.2, std::make_pair(
true, 0.
f));
75 auto hashFunc = stl_helpers::hash<decltype(
t)>{};
76 EXPECT_EQ(hashVal, hashFunc(
t));
79 TEST(HashHelpers, hashVector)
83 auto hashFunc = stl_helpers::hash<decltype(
v)>{};
84 EXPECT_EQ(hashVal, hashFunc(
v));