]>
git.saurik.com Git - apple/xnu.git/blob - tests/bounded_ptr_src/assign.nullptr.cpp
3 // bounded_ptr& operator=(std::nullptr_t);
7 #include <libkern/c++/bounded_ptr.h>
8 #include <darwintest.h>
9 #include <darwintest_utils.h>
10 #include "test_utils.h"
12 #define _assert(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__)
16 template <typename T
, typename TQual
>
22 // Assign from nullptr
24 test_bounded_ptr
<TQual
> p(&obj
, &obj
, &obj
+ 1);
25 _assert(p
!= nullptr);
26 test_bounded_ptr
<TQual
>& ref
= (p
= nullptr);
28 _assert(p
== nullptr);
33 test_bounded_ptr
<TQual
> p(&obj
, &obj
, &obj
+ 1);
34 _assert(p
!= nullptr);
35 test_bounded_ptr
<TQual
>& ref
= (p
= NULL
);
37 _assert(p
== nullptr);
42 test_bounded_ptr
<TQual
> p(&obj
, &obj
, &obj
+ 1);
43 _assert(p
!= nullptr);
44 test_bounded_ptr
<TQual
>& ref
= (p
= 0);
46 _assert(p
== nullptr);
50 T_DECL(assign_nullptr
, "bounded_ptr.assign.nullptr") {
53 tests
<T
, T
volatile>();
54 tests
<T
, T
const volatile>();