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