]> git.saurik.com Git - apple/xnu.git/blame - tests/safe_allocation_src/ctor.default.cpp
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / tests / safe_allocation_src / ctor.default.cpp
CommitLineData
f427ee49
A
1//
2// Tests for
3// explicit safe_allocation();
4//
5
6#include <libkern/c++/safe_allocation.h>
7#include <darwintest.h>
8#include "test_utils.h"
9
10struct T {
11 int i;
12};
13
14template <typename T>
15static void
16tests()
17{
18 {
19 test_safe_allocation<T> array;
20 CHECK(array.data() == nullptr);
21 CHECK(array.size() == 0);
22 CHECK(array.begin() == array.end());
23 }
24 {
25 test_safe_allocation<T> array{};
26 CHECK(array.data() == nullptr);
27 CHECK(array.size() == 0);
28 CHECK(array.begin() == array.end());
29 }
30 {
31 test_safe_allocation<T> array = test_safe_allocation<T>();
32 CHECK(array.data() == nullptr);
33 CHECK(array.size() == 0);
34 CHECK(array.begin() == array.end());
35 }
36}
37
38T_DECL(ctor_default, "safe_allocation.ctor.default") {
39 tests<T>();
40 tests<T const>();
41}