1#include <sysio/vm/allocator.hpp>
11 std::size_t sz =
sizeof(
T);
12 return std::align(
alignof(
T),
sizeof(
T),
p, sz) !=
nullptr;
15TEST_CASE(
"Testing growable_allocator alignment",
"[growable_allocator]") {
17 unsigned char * cptr = alloc.
alloc<
unsigned char>(1);
28 *lptr = 0x8899102030405060u;
29 CHECK(*cptr == 0x11u);
30 CHECK(*sptr == 0x2233u);
31 CHECK(*iptr == 0x44556677u);
32 CHECK(*lptr == 0x8899102030405060u);
35TEST_CASE(
"Testing maximum single allocation",
"[growable_allocator]") {
37 char * ptr = alloc.
alloc<
char>(0x40000000);
39 ptr[0x3FFFFFFF] =
'z';
44TEST_CASE(
"Testing maximum multiple allocation",
"[growable_allocator]") {
46 for(
int i = 0; i < 4; ++i) {
47 char * ptr = alloc.
alloc<
char>(0x10000000);
49 ptr[0x0FFFFFFF] =
'z';
54TEST_CASE(
"Testing too large single allocation",
"[growable_allocator]") {
59TEST_CASE(
"Testing too large multiple allocation",
"[growable_allocator]") {
61 alloc.
alloc<
char>(0x10000000);
62 alloc.
alloc<
char>(0x10000000);
63 alloc.
alloc<
char>(0x10000000);
67TEST_CASE(
"Testing maximum initial size",
"[growable_allocator]") {
69 char * ptr = alloc.
alloc<
char>(0x40000000);
71 ptr[0x3FFFFFFF] =
'z';
74TEST_CASE(
"Testing too large initial size",
"[growable_allocator]") {
82TEST_CASE(
"Testing maximum aligned allocation",
"[growable_allocator]") {
84 struct alignas(8) aligned_t {
char a[8]; };
85 alloc.
alloc<
char>(0x3FFFFFF4);
86 aligned_t * ptr = alloc.
alloc<aligned_t>(1);
89 alloc.
alloc<aligned_t>(0);
93TEST_CASE(
"Testing reclaim",
"[growable_allocator]") {
95 int * ptr1 = alloc.
alloc<
int>(10);
97 int * ptr2 = alloc.
alloc<
int>(10);
98 CHECK(ptr2 == ptr1 + 2);
bool check_alignment(T *ptr)
void reclaim(const T *ptr, size_t size=0)
#define CHECK_THROWS_AS(expr, exceptionType)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
#define T(meth, val, expected)
unsigned __int64 uint64_t