1*5e3eaea3SApple OSS Distributions // 2*5e3eaea3SApple OSS Distributions // Tests for 3*5e3eaea3SApple OSS Distributions // explicit operator bool() const; 4*5e3eaea3SApple OSS Distributions // 5*5e3eaea3SApple OSS Distributions 6*5e3eaea3SApple OSS Distributions #include <libkern/c++/bounded_ptr.h> 7*5e3eaea3SApple OSS Distributions #include <darwintest.h> 8*5e3eaea3SApple OSS Distributions #include <darwintest_utils.h> 9*5e3eaea3SApple OSS Distributions #include "test_utils.h" 10*5e3eaea3SApple OSS Distributions 11*5e3eaea3SApple OSS Distributions #define _assert(...) T_ASSERT_TRUE((__VA_ARGS__), # __VA_ARGS__) 12*5e3eaea3SApple OSS Distributions 13*5e3eaea3SApple OSS Distributions struct T { }; 14*5e3eaea3SApple OSS Distributions 15*5e3eaea3SApple OSS Distributions template <typename T> 16*5e3eaea3SApple OSS Distributions static void tests()17*5e3eaea3SApple OSS Distributionstests() 18*5e3eaea3SApple OSS Distributions { 19*5e3eaea3SApple OSS Distributions { 20*5e3eaea3SApple OSS Distributions test_bounded_ptr<T> p = nullptr; 21*5e3eaea3SApple OSS Distributions if (p) { 22*5e3eaea3SApple OSS Distributions _assert(false); 23*5e3eaea3SApple OSS Distributions } 24*5e3eaea3SApple OSS Distributions _assert(!p); 25*5e3eaea3SApple OSS Distributions } 26*5e3eaea3SApple OSS Distributions { 27*5e3eaea3SApple OSS Distributions T t; 28*5e3eaea3SApple OSS Distributions test_bounded_ptr<T> p(&t, &t, &t + 1); 29*5e3eaea3SApple OSS Distributions if (p) { 30*5e3eaea3SApple OSS Distributions } else { 31*5e3eaea3SApple OSS Distributions _assert(false); 32*5e3eaea3SApple OSS Distributions } 33*5e3eaea3SApple OSS Distributions _assert(!!p); 34*5e3eaea3SApple OSS Distributions } 35*5e3eaea3SApple OSS Distributions } 36*5e3eaea3SApple OSS Distributions 37*5e3eaea3SApple OSS Distributions T_DECL(operator_bool, "bounded_ptr.operator.bool") { 38*5e3eaea3SApple OSS Distributions tests<T>(); 39*5e3eaea3SApple OSS Distributions tests<T const>(); 40*5e3eaea3SApple OSS Distributions tests<T volatile>(); 41*5e3eaea3SApple OSS Distributions tests<T const volatile>(); 42*5e3eaea3SApple OSS Distributions } 43