Summary:
"Wouldn't this test case still pass if the hash function didn't depend on the value?
It would be nice to verify that different tuple values produce different hash values (or maybe there's another test that verifies that), especially since this is a tricky thing to get right."
I think there's not much chance of this failing since it's just leveraging hash_combine and that's already tested. But it's easy to add another sanity check, so here we are.
Test Plan: runtests
Reviewed By: tulloch@fb.com
FB internal diff:
D890448
Blame Revision:
D888796
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));
+}