folly/Hash.h add a test to ensure different hashes
[folly.git] / folly / test / HashTest.cpp
index 6ed9a280a1d9ea0a3c58b651be730e94e9650966..5b8840f5f24b6d3bc18725a37af7406b3635d0e2 100644 (file)
@@ -237,3 +237,15 @@ TEST(Hash, std_tuple) {
   m[t] = "bar";
   EXPECT_EQ("bar", m[t]);
 }
+
+TEST(Hash, std_tuple_different_hash) {
+  typedef std::tuple<int64_t, std::string, int32_t> tuple3;
+  tuple3 t1(42, "foo", 1);
+  tuple3 t2(9, "bar", 3);
+  tuple3 t3(42, "foo", 3);
+
+  EXPECT_NE(std::hash<tuple3>()(t1),
+            std::hash<tuple3>()(t2));
+  EXPECT_NE(std::hash<tuple3>()(t1),
+            std::hash<tuple3>()(t3));
+}