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)); +}