[cplusplus] Test hashing shared_ptr / unique_ptr
This commit is contained in:
parent
51ca1c9b59
commit
7aacdd05bd
|
@ -62,6 +62,7 @@
|
||||||
#include "hb-cplusplus.hh"
|
#include "hb-cplusplus.hh"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -108,5 +109,16 @@ main ()
|
||||||
|
|
||||||
hb::unique_ptr<hb_buffer_t> pb5 {pb3.reference ()};
|
hb::unique_ptr<hb_buffer_t> 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<hb_buffer_t *> hash {};
|
||||||
|
std::hash<hb::shared_ptr<hb_buffer_t>> hash2 {};
|
||||||
|
std::hash<hb::unique_ptr<hb_buffer_t>> hash3 {};
|
||||||
|
|
||||||
|
assert (hash (b) == hash2 (pb4));
|
||||||
|
assert (hash2 (pb4) == hash2 (pb2));
|
||||||
|
assert (hash (b) == hash3 (pb5));
|
||||||
|
|
||||||
return pb == pb.get_empty () || pb == pb2;
|
return pb == pb.get_empty () || pb == pb2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue