From 37516080db6878bef6fb1e6c5542165f3f982792 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sat, 23 Aug 2025 22:07:34 +0200 Subject: code upgrade --- include/assert.h | 17 +++++++++-------- include/testing.h | 10 ++++++++++ include/types.h | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/assert.h b/include/assert.h index ad9c2fd..aa62bd1 100644 --- a/include/assert.h +++ b/include/assert.h @@ -3,12 +3,13 @@ #include #include -#define assert(condition, ...) \ - do { \ - if (!(condition)) { \ - fprintf(stderr, "Assertion failed: %s:%d in %s(): ", __FILE__, __LINE__, __func__); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ - abort(); \ - } \ +#define assert(condition, ...) \ + do { \ + if (!(condition)) { \ + fprintf(stderr, "Assertion failed: %s:%d in %s(): ", __FILE__, \ + __LINE__, __func__); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + abort(); \ + } \ } while (0) diff --git a/include/testing.h b/include/testing.h index 9e0c022..dc070d3 100644 --- a/include/testing.h +++ b/include/testing.h @@ -1,4 +1,6 @@ +#pragma once #include +#include #define t_assert(fact) \ if (!(fact)) { \ @@ -22,3 +24,11 @@ #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; \ + } diff --git a/include/types.h b/include/types.h index da3a093..6df9510 100644 --- a/include/types.h +++ b/include/types.h @@ -1,7 +1,7 @@ +#include #include #include #include -#include typedef ptrdiff_t size; typedef char byte; @@ -9,7 +9,7 @@ typedef uintptr_t uptr; typedef int32_t i32; typedef uint64_t u64; typedef float f32; -typedef __m256i byte_32; +typedef __m256i bytex32; #define sizeof(x) (size)sizeof(x) #define countof(a) (sizeof(a) / sizeof(*(a))) -- cgit v1.3