@@ -110,26 +110,27 @@ void testHash(LambdaType &&objFactory) {
110
110
111
111
const int NumObjects = 100 ;
112
112
113
- std::unordered_map<T, bool > MapObjToBool{};
113
+ std::unordered_set<size_t > HashSet{};
114
+
114
115
T Obj1 = objFactory ();
115
116
T Obj2 = objFactory ();
116
117
T Obj3 = objFactory ();
117
118
T Obj4 = objFactory ();
118
119
119
- ASSERT_TRUE (MapObjToBool .insert ({Obj1, true } ).second );
120
- ASSERT_TRUE (MapObjToBool .insert ({Obj2, true } ).second );
120
+ ASSERT_TRUE (HashSet .insert (std::hash<T>{}(Obj1) ).second );
121
+ ASSERT_TRUE (HashSet .insert (std::hash<T>{}(Obj2) ).second );
121
122
122
- // Insert objects and destroy them immediately to confirm that this doesn't
123
- // create collisions with later insertions .
123
+ // Create objects and destroy them immediately to confirm that the
124
+ // hashes are unique and are not reused .
124
125
for (int i = 0 ; i < NumObjects; ++i) {
125
126
T ObjI = objFactory ();
126
- ASSERT_TRUE (MapObjToBool .insert ({ObjI, true } ).second );
127
+ ASSERT_TRUE (HashSet .insert (std::hash<T>{}(ObjI) ).second );
127
128
}
128
129
129
- ASSERT_TRUE (MapObjToBool .insert ({Obj3, true } ).second );
130
- ASSERT_TRUE (MapObjToBool .insert ({Obj4, true } ).second );
130
+ ASSERT_TRUE (HashSet .insert (std::hash<T>{}(Obj3) ).second );
131
+ ASSERT_TRUE (HashSet .insert (std::hash<T>{}(Obj4) ).second );
131
132
132
- ASSERT_TRUE (MapObjToBool .size () == (NumObjects + 4 ));
133
+ ASSERT_TRUE (HashSet .size () == (NumObjects + 4 ));
133
134
}
134
135
135
136
TEST_F (CommandGraphTest, ModifiableGraphHash) {
0 commit comments