]> git.saurik.com Git - apple/xnu.git/blame - tests/bounded_array_ref_src/operator.bool.cpp
xnu-7195.81.3.tar.gz
[apple/xnu.git] / tests / bounded_array_ref_src / operator.bool.cpp
CommitLineData
f427ee49
A
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
11struct T { int i; };
12
13template <typename T>
14static void
15tests()
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
35T_DECL(operator_bool, "bounded_array_ref.operator.bool") {
36 tests<T>();
37 tests<T const>();
38}