diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-08-23 22:07:34 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-08-27 11:46:25 +0200 |
| commit | 37516080db6878bef6fb1e6c5542165f3f982792 (patch) | |
| tree | d6d37921249b52b53df7166aaf67db510469f3c4 /include/testing.h | |
| parent | b22b59adb72371d6ca7072eca2c166f4c2534677 (diff) | |
code upgrade
Diffstat (limited to 'include/testing.h')
| -rw-r--r-- | include/testing.h | 10 |
1 files changed, 10 insertions, 0 deletions
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 <stdio.h> +#include <string.h> #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; \ + } |
