diff options
author | Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com> | 2020-11-03 16:56:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-03 16:56:09 -0800 |
commit | 9150ce9a95680268b16c4fcf3e727ae76ecb9bac (patch) | |
tree | eceb6b8cd8b0fcbb3900c5f22a4a44905d9a87b3 | |
parent | a150aaa4ed355e88834877c9f39eadd4526e3b8f (diff) | |
download | Microsoft-GSL-9150ce9a95680268b16c4fcf3e727ae76ecb9bac.tar.gz |
Adding std::hash<not_null<T>> tests to notnull_tests.cpp (#947)
* added std::hash<not_null> tests
* nl
-rw-r--r-- | tests/notnull_tests.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp index 0578131..b95bb01 100644 --- a/tests/notnull_tests.cpp +++ b/tests/notnull_tests.cpp @@ -533,3 +533,18 @@ TEST(notnull_tests, TestMakeNotNull) } #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)); +} |