]> git.saurik.com Git - apple/xnu.git/blame_incremental - tests/intrusive_shared_ptr_src/ctor.ptr.retain.cpp
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / intrusive_shared_ptr_src / ctor.ptr.retain.cpp
... / ...
CommitLineData
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
11struct T { int i; };
12
13template <typename T, typename TQual>
14static void
15tests()
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
33T_DECL(ctor_ptr_retain, "intrusive_shared_ptr.ctor.ptr.retain") {
34 tests<T, T>();
35 tests<T, T const>();
36}