diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-08-24 22:53:21 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-08-27 11:46:25 +0200 |
| commit | 8e478e06c2c09e8d74fcaa6cca84f7db14d23265 (patch) | |
| tree | c1913a33402c9b63f6cbc1288d05d1ef4c48bb7c /include | |
| parent | dd2c70e878e4bc7fcf26f33523a45f0d854a29e4 (diff) | |
improved testing & src cleanup
Diffstat (limited to 'include')
| -rw-r--r-- | include/str.h | 12 | ||||
| -rw-r--r-- | include/testing.h | 8 |
2 files changed, 14 insertions, 6 deletions
diff --git a/include/str.h b/include/str.h index 153eebc..2d2eb93 100644 --- a/include/str.h +++ b/include/str.h @@ -6,20 +6,18 @@ #include "../include/memory.h" #include "../include/types.h" -#define S(s) \ - (Str) { s, lengthof(s) } typedef struct { byte *data; size len; } Str; -typedef struct { - byte *data; - size len; -} StrView; u64 Str_hash64(Str s); Str Str_copy(Arena *a, byte *data, size len); i32 Str_fprint(FILE *w, Str s); +typedef struct { + byte *data; + size len; +} StrView; StrView Str_view(byte *data, size len); Str StrView_copy(Arena *a, StrView s); @@ -28,3 +26,5 @@ Str StrView_copy(Arena *a, StrView s); #define Str_equals(a, b) \ ((a).len == (b).len) && (!(a).len || !memcmp((a).data, (b).data, (a).len)) #define Str_fprint(w, s) fprintf(w, "%.*s", (i32)(s).len, (s).data) +#define S(s) \ + (Str) { s, lengthof(s) } diff --git a/include/testing.h b/include/testing.h index 754733b..1ca460b 100644 --- a/include/testing.h +++ b/include/testing.h @@ -2,6 +2,14 @@ #include <stdio.h> #include <string.h> +#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, \ |
