diff --git a/test/api/test-cplusplus.cc b/test/api/test-cplusplus.cc index d742750f6..28b5e21ab 100644 --- a/test/api/test-cplusplus.cc +++ b/test/api/test-cplusplus.cc @@ -62,6 +62,7 @@ #include "hb-cplusplus.hh" #include +#include #include int @@ -108,5 +109,16 @@ main () hb::unique_ptr pb5 {pb3.reference ()}; + + /* Test that shared_ptr / unique_ptr are std::hash'able, and that they + * return the same hash (which is the underlying pointer's hash. */ + std::hash hash {}; + std::hash> hash2 {}; + std::hash> hash3 {}; + + assert (hash (b) == hash2 (pb4)); + assert (hash2 (pb4) == hash2 (pb2)); + assert (hash (b) == hash3 (pb5)); + return pb == pb.get_empty () || pb == pb2; }