mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Adding std::hash<not_null<T>> tests to notnull_tests.cpp (#947)
* added std::hash<not_null> tests * nl
This commit is contained in:
parent
a150aaa4ed
commit
9150ce9a95
@ -533,3 +533,18 @@ TEST(notnull_tests, TestMakeNotNull)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(notnull_tests, TestStdHash)
|
||||||
|
{
|
||||||
|
int x = 42;
|
||||||
|
int y = 99;
|
||||||
|
not_null<int*> nn{&x};
|
||||||
|
const not_null<int*> cnn{&x};
|
||||||
|
|
||||||
|
std::hash<not_null<int*>> hash_nn;
|
||||||
|
std::hash<int*> hash_intptr;
|
||||||
|
|
||||||
|
EXPECT_TRUE(hash_nn(nn) == hash_intptr(&x));
|
||||||
|
EXPECT_FALSE(hash_nn(nn) == hash_intptr(&y));
|
||||||
|
EXPECT_FALSE(hash_nn(nn) == hash_intptr(nullptr));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user