]> git.saurik.com Git - apple/xnu.git/blobdiff - tests/bounded_array_ref_src/operator.bool.cpp
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / tests / bounded_array_ref_src / operator.bool.cpp
diff --git a/tests/bounded_array_ref_src/operator.bool.cpp b/tests/bounded_array_ref_src/operator.bool.cpp
new file mode 100644 (file)
index 0000000..bd52b9f
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// Tests for
+//  explicit operator bool() const;
+//
+
+#include <libkern/c++/bounded_array_ref.h>
+#include "test_policy.h"
+#include <darwintest.h>
+#include <darwintest_utils.h>
+
+struct T { int i; };
+
+template <typename T>
+static void
+tests()
+{
+       {
+               test_bounded_array_ref<T> const view;
+               if (view) {
+                       CHECK(false);
+               }
+               CHECK(!view);
+       }
+       {
+               T array[5] = {};
+               test_bounded_array_ref<T> const view(array);
+               if (view) {
+               } else {
+                       CHECK(false);
+               }
+               CHECK(!!view);
+       }
+}
+
+T_DECL(operator_bool, "bounded_array_ref.operator.bool") {
+       tests<T>();
+       tests<T const>();
+}