Skip to content

Commit eb2f79b

Browse files
committed
Update hash unit test
1 parent ccf64e5 commit eb2f79b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

sycl/unittests/Extensions/CommandGraph/CommonReferenceSemantics.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,27 @@ void testHash(LambdaType &&objFactory) {
110110

111111
const int NumObjects = 100;
112112

113-
std::unordered_map<T, bool> MapObjToBool{};
113+
std::unordered_set<size_t> HashSet{};
114+
114115
T Obj1 = objFactory();
115116
T Obj2 = objFactory();
116117
T Obj3 = objFactory();
117118
T Obj4 = objFactory();
118119

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);
121122

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.
124125
for (int i = 0; i < NumObjects; ++i) {
125126
T ObjI = objFactory();
126-
ASSERT_TRUE(MapObjToBool.insert({ObjI, true}).second);
127+
ASSERT_TRUE(HashSet.insert(std::hash<T>{}(ObjI)).second);
127128
}
128129

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);
131132

132-
ASSERT_TRUE(MapObjToBool.size() == (NumObjects + 4));
133+
ASSERT_TRUE(HashSet.size() == (NumObjects + 4));
133134
}
134135

135136
TEST_F(CommandGraphTest, ModifiableGraphHash) {

0 commit comments

Comments
 (0)