aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>2020-11-03 16:56:09 -0800
committerGitHub <noreply@github.com>2020-11-03 16:56:09 -0800
commit9150ce9a95680268b16c4fcf3e727ae76ecb9bac (patch)
treeeceb6b8cd8b0fcbb3900c5f22a4a44905d9a87b3
parenta150aaa4ed355e88834877c9f39eadd4526e3b8f (diff)
downloadMicrosoft-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.cpp15
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));
+}