From 89b4dfa3e89c6dd6bc430f4468e26e2e3cfdf129 Mon Sep 17 00:00:00 2001 From: Ivar Fatland Date: Fri, 3 Oct 2025 22:05:00 +0200 Subject: [PATCH] make testing more robust --- .snippets/c.snippets | 7 +++++++ _allocator_impl.c | 5 +++++ makefile | 2 +- test_std_allocator.c | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .snippets/c.snippets create mode 100644 _allocator_impl.c diff --git a/.snippets/c.snippets b/.snippets/c.snippets new file mode 100644 index 0000000..b2fc2f9 --- /dev/null +++ b/.snippets/c.snippets @@ -0,0 +1,7 @@ +snippet testfile + #include + #include "allocator.h" + + Test($1, $2) { + $0 + } diff --git a/_allocator_impl.c b/_allocator_impl.c new file mode 100644 index 0000000..55dcb3d --- /dev/null +++ b/_allocator_impl.c @@ -0,0 +1,5 @@ +// This is used to have a single file that implements the allocators when all +// the test files are compiled together. + +#define ALLOCATOR_IMPLEMENTATION +#include "allocator.h" diff --git a/makefile b/makefile index 0e1d55d..7169be1 100644 --- a/makefile +++ b/makefile @@ -18,7 +18,7 @@ test: echo "No test files found!"; \ else \ echo "Compiling all test files into $(TESTBIN)..."; \ - $(CC) $(CFLAGS) $$files -o $(TESTBIN) $(LDFLAGS); \ + $(CC) $(CFLAGS) _allocator_impl.c $$files -o $(TESTBIN) $(LDFLAGS); \ echo "Running tests..."; \ $(TESTBIN); \ fi diff --git a/test_std_allocator.c b/test_std_allocator.c index 3d174e4..a764e4c 100644 --- a/test_std_allocator.c +++ b/test_std_allocator.c @@ -1,7 +1,7 @@ #include -#define ALLOCATOR_IMPLEMENTATION #include "allocator.h" + Test(std_allocator, test) { allocator_t this = allocator_stdlib; void *ptr = allocator_alloc(this, 10);