apfl/src/alloc_test.c

26 lines
510 B
C
Raw Normal View History

#include <stdint.h>
#include "test.h"
#include "alloc.h"
#define ELEMSIZE 256
typedef char elemtype[ELEMSIZE];
TEST(overflow, t) {
t->allocation_autofail = false;
struct apfl_allocator allocator = test_allocator(t);
size_t maxelems = SIZE_MAX / sizeof(elemtype);
elemtype *mem = ALLOC_LIST(allocator, elemtype, maxelems + 2);
if (mem != NULL) {
test_fatalf(t, "Could unexpectedly allocate more than maxelems elements.");
}
}
TESTS_BEGIN
ADDTEST(overflow),
TESTS_END