// // Make sure `safe_allocation` can be used to create a two-dimensional array. // // Note that we don't really recommend using that representation for two // dimensional arrays because other representations are better, but it // should at least work. // #include #include #include "test_utils.h" struct T { int i; }; template static void tests() { test_safe_allocation > array(10, libkern::allocate_memory); for (int i = 0; i < 10; i++) { array[i] = test_safe_allocation(10, libkern::allocate_memory); for (int j = 0; j < 10; ++j) { array[i][j] = i + j; } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; ++j) { CHECK(array[i][j] == i + j); } } } T_DECL(usage_two_dimensions, "safe_allocation.usage.two_dimensions", T_META_TAG_VM_PREFERRED) { tests(); }