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_array_ref.h> 7*2c2f96dcSApple OSS Distributions #include "test_policy.h" 8*2c2f96dcSApple OSS Distributions #include <darwintest.h> 9*2c2f96dcSApple OSS Distributions #include <darwintest_utils.h> 10*2c2f96dcSApple OSS Distributions 11*2c2f96dcSApple OSS Distributions struct T { int i; }; 12*2c2f96dcSApple OSS Distributions 13*2c2f96dcSApple OSS Distributions template <typename T> 14*2c2f96dcSApple OSS Distributions static void tests()15*2c2f96dcSApple OSS Distributionstests() 16*2c2f96dcSApple OSS Distributions { 17*2c2f96dcSApple OSS Distributions { 18*2c2f96dcSApple OSS Distributions test_bounded_array_ref<T> const view; 19*2c2f96dcSApple OSS Distributions if (view) { 20*2c2f96dcSApple OSS Distributions CHECK(false); 21*2c2f96dcSApple OSS Distributions } 22*2c2f96dcSApple OSS Distributions CHECK(!view); 23*2c2f96dcSApple OSS Distributions } 24*2c2f96dcSApple OSS Distributions { 25*2c2f96dcSApple OSS Distributions T array[5] = {}; 26*2c2f96dcSApple OSS Distributions test_bounded_array_ref<T> const view(array); 27*2c2f96dcSApple OSS Distributions if (view) { 28*2c2f96dcSApple OSS Distributions } else { 29*2c2f96dcSApple OSS Distributions CHECK(false); 30*2c2f96dcSApple OSS Distributions } 31*2c2f96dcSApple OSS Distributions CHECK(!!view); 32*2c2f96dcSApple OSS Distributions } 33*2c2f96dcSApple OSS Distributions } 34*2c2f96dcSApple OSS Distributions 35*2c2f96dcSApple OSS Distributions T_DECL(operator_bool, "bounded_array_ref.operator.bool") { 36*2c2f96dcSApple OSS Distributions tests<T>(); 37*2c2f96dcSApple OSS Distributions tests<T const>(); 38*2c2f96dcSApple OSS Distributions } 39