// // Tests for // explicit safe_allocation(size_t n, allocate_memory_zero_t); // #include #include #include "test_utils.h" #include struct T { int i; }; template static void tests() { { test_safe_allocation const array(10, libkern::allocate_memory_zero); CHECK(array.data() != nullptr); CHECK(array.size() == 10); CHECK(array.begin() == array.data()); CHECK(array.end() == array.data() + 10); auto const byteArray = reinterpret_cast(array.data()); size_t const byteLength = array.size() * sizeof(T); CHECK(std::all_of(byteArray, byteArray + byteLength, [](const auto& elem){ return elem == 0; })); } } T_DECL(ctor_allocate_zero, "safe_allocation.ctor.allocate_zero") { tests(); tests(); tests(); tests(); }