From 9150ce9a95680268b16c4fcf3e727ae76ecb9bac Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Tue, 3 Nov 2020 16:56:09 -0800 Subject: [PATCH] Adding std::hash> tests to notnull_tests.cpp (#947) * added std::hash tests * nl --- tests/notnull_tests.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 nn{&x}; + const not_null cnn{&x}; + + std::hash> hash_nn; + std::hash 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)); +}