]> git.saurik.com Git - apple/xnu.git/blob - tests/intrusive_shared_ptr_src/ctor.ptr.no_retain.cpp
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / intrusive_shared_ptr_src / ctor.ptr.no_retain.cpp
1 //
2 // Tests for
3 // explicit intrusive_shared_ptr(pointer p, no_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::no_retain);
22 CHECK(ptr.get() == &obj);
23 CHECK(test_policy::retain_count == 0);
24 }
25 {
26 test_policy::retain_count = 0;
27 libkern::intrusive_shared_ptr<TQual, test_policy> ptr{&obj, libkern::no_retain};
28 CHECK(ptr.get() == &obj);
29 CHECK(test_policy::retain_count == 0);
30 }
31 }
32
33 T_DECL(ctor_ptr_no_retain, "intrusive_shared_ptr.ctor.ptr.no_retain") {
34 tests<T, T>();
35 tests<T, T const>();
36 }