]>
git.saurik.com Git - apple/xnu.git/blob - tests/intrusive_shared_ptr_src/assign.nullptr.cpp
3 // intrusive_shared_ptr& operator=(std::nullptr_t);
6 #include <libkern/c++/intrusive_shared_ptr.h>
7 #include <darwintest.h>
8 #include "test_policy.h"
20 // Assign nullptr to non-null
22 tracked_shared_ptr
<T
> ptr(&obj
, libkern::retain
);
23 tracking_policy::reset();
24 tracked_shared_ptr
<T
>& ref
= (ptr
= nullptr);
25 CHECK(tracking_policy::releases
== 1);
26 CHECK(tracking_policy::retains
== 0);
28 CHECK(ptr
.get() == nullptr);
31 // Assign nullptr to null
33 tracked_shared_ptr
<T
> ptr
= nullptr;
34 tracking_policy::reset();
35 tracked_shared_ptr
<T
>& ref
= (ptr
= nullptr);
36 CHECK(tracking_policy::releases
== 0);
37 CHECK(tracking_policy::retains
== 0);
39 CHECK(ptr
.get() == nullptr);
43 T_DECL(assign_nullptr
, "intrusive_shared_ptr.assign.nullptr") {