]>
git.saurik.com Git - apple/xnu.git/blob - tests/safe_allocation_src/usage.two_dimensions.cpp
2 // Make sure `safe_allocation` can be used to create a two-dimensional array.
4 // Note that we don't really recommend using that representation for two
5 // dimensional arrays because other representations are better, but it
6 // should at least work.
9 #include <libkern/c++/safe_allocation.h>
10 #include <darwintest.h>
11 #include "test_utils.h"
21 test_safe_allocation
<test_safe_allocation
<int> > array(10, libkern::allocate_memory
);
23 for (int i
= 0; i
< 10; i
++) {
24 array
[i
] = test_safe_allocation
<int>(10, libkern::allocate_memory
);
25 for (int j
= 0; j
< 10; ++j
) {
30 for (int i
= 0; i
< 10; i
++) {
31 for (int j
= 0; j
< 10; ++j
) {
32 CHECK(array
[i
][j
] == i
+ j
);
37 T_DECL(usage_two_dimensions
, "safe_allocation.usage.two_dimensions") {