]>
Commit | Line | Data |
---|---|---|
1 | // | |
2 | // Tests for | |
3 | // explicit intrusive_shared_ptr(pointer p, retain_t); | |
4 | // | |
5 | ||
6 | #include <libkern/c++/intrusive_shared_ptr.h> | |
7 | #include <darwintest.h> | |
8 | #include <darwintest_utils.h> | |
9 | #include "test_policy.h" | |
10 | ||
11 | struct T { int i; }; | |
12 | ||
13 | template <typename T, typename TQual> | |
14 | static void | |
15 | tests() | |
16 | { | |
17 | T obj{0}; | |
18 | ||
19 | { | |
20 | test_policy::retain_count = 0; | |
21 | libkern::intrusive_shared_ptr<TQual, test_policy> ptr(&obj, libkern::retain); | |
22 | CHECK(ptr.get() == &obj); | |
23 | CHECK(test_policy::retain_count == 1); | |
24 | } | |
25 | { | |
26 | test_policy::retain_count = 0; | |
27 | libkern::intrusive_shared_ptr<TQual, test_policy> ptr{&obj, libkern::retain}; | |
28 | CHECK(ptr.get() == &obj); | |
29 | CHECK(test_policy::retain_count == 1); | |
30 | } | |
31 | } | |
32 | ||
33 | T_DECL(ctor_ptr_retain, "intrusive_shared_ptr.ctor.ptr.retain") { | |
34 | tests<T, T>(); | |
35 | tests<T, T const>(); | |
36 | } |