From 6fd6aa9b61f080487b29be51681479a7d0a2b57d Mon Sep 17 00:00:00 2001 From: Randy Jordan Date: Sun, 18 Jan 2026 19:12:27 -0600 Subject: [PATCH] min test --- tests/05_allocation.c | 22 ++++++++++++++++++++++ tests/06_backing.c | 24 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/05_allocation.c create mode 100644 tests/06_backing.c diff --git a/tests/05_allocation.c b/tests/05_allocation.c new file mode 100644 index 0000000..3e5d166 --- /dev/null +++ b/tests/05_allocation.c @@ -0,0 +1,22 @@ +#define DEBUG +#include +#include +#include "../include/arena.h" +#include "../include/mem.h" +#include + +int main(void){ + size_t nbytes = 10; + Arena a = ARENA(0,nbytes); + assert(a.beg != NULL); + assert( mem_is_zero(a.beg, nbytes)); + + char *ptr = ARENA_ALLOC(0, &a, nbytes,nbytes,1); + assert(ptr != NULL); + memcpy(ptr,"abcdefghij",nbytes); + assert(memcmp(ptr, "abcdefghij", nbytes) == 0); + + + free(ptr); + return EXIT_SUCCESS; +} diff --git a/tests/06_backing.c b/tests/06_backing.c new file mode 100644 index 0000000..b89fc9f --- /dev/null +++ b/tests/06_backing.c @@ -0,0 +1,24 @@ +#define DEBUG +#include +#include +#include "../include/arena.h" +#include "../include/mem.h" +#include + +int main(void){ + const size_t nbytes = 10; + char *buf[nbytes]; + memset(buf,0,nbytes); + Arena a; + ARENA_BACK(&a,buf,nbytes); + assert(a.beg != NULL); + assert( mem_is_zero(a.beg, nbytes)); + + char *ptr = ARENA_ALLOC(0, &a, nbytes,nbytes,1); + assert(ptr != NULL); + memcpy(ptr,"abcdefghij",nbytes); + assert(memcmp(ptr, "abcdefghij", nbytes) == 0); + + + return EXIT_SUCCESS; +}