From cf534d762754860ed5b714974f99acd282d48b3b Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Wed, 8 Apr 2026 13:14:27 +0200 Subject: Restructure into src/{std,json}/ Co-Authored-By: Claude Sonnet 4.6 --- src/std/testing.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/std/testing.h (limited to 'src/std/testing.h') diff --git a/src/std/testing.h b/src/std/testing.h new file mode 100644 index 0000000..388c778 --- /dev/null +++ b/src/std/testing.h @@ -0,0 +1,36 @@ +#pragma once +#include +#include + +#include "memory.h" + +typedef struct { + size size; + byte *content; +} MemoryFile; +MemoryFile load_file(Arena *a, const char *filename); + +#define t_assert_equal(a, b) \ + if (!(a == b)) { \ + fprintf(stderr, \ + "Assertion failed: %d (%s) != %d (%s) at %s:%d in %s()\n", \ + (i32)a, #a, (i32)b, #b, __FILE__, __LINE__, __func__); \ + return 1; \ + } + +#define t_assert_fequal(a, b) \ + if ((a - b) > 1e-6 || (b - a) > 1e-6) { \ + fprintf(stderr, \ + "Assertion failed: %f (%s) != %f (%s) at %s:%d in %s()\n", a, \ + #a, b, #b, __FILE__, __LINE__, __func__); \ + return 1; \ + } + +#define t_assert_strequal(a, b) \ + if ((a.len != b.len) || (a.len && memcmp(a.data, b.data, a.len))) { \ + fprintf(stderr, \ + "Assertion failed: %.*s (%s) != %.*s (%s) at %s:%d in %s()\n", \ + (i32)a.len, a.data, #a, (i32)b.len, b.data, #b, __FILE__, \ + __LINE__, __func__); \ + return 1; \ + } -- cgit v1.3