]> git.saurik.com Git - apple/xnu.git/blob - tests/bounded_array_ref_src/operator.bool.cpp
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / bounded_array_ref_src / operator.bool.cpp
1 //
2 // Tests for
3 // explicit operator bool() const;
4 //
5
6 #include <libkern/c++/bounded_array_ref.h>
7 #include "test_policy.h"
8 #include <darwintest.h>
9 #include <darwintest_utils.h>
10
11 struct T { int i; };
12
13 template <typename T>
14 static void
15 tests()
16 {
17 {
18 test_bounded_array_ref<T> const view;
19 if (view) {
20 CHECK(false);
21 }
22 CHECK(!view);
23 }
24 {
25 T array[5] = {};
26 test_bounded_array_ref<T> const view(array);
27 if (view) {
28 } else {
29 CHECK(false);
30 }
31 CHECK(!!view);
32 }
33 }
34
35 T_DECL(operator_bool, "bounded_array_ref.operator.bool") {
36 tests<T>();
37 tests<T const>();
38 }