diff options
| author | Albert Cervin <albert@acervin.com> | 2022-11-02 22:20:04 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2022-11-16 23:33:49 +0100 |
| commit | 2f4cb88d5c60f725323739300bb49dfa8923e7d5 (patch) | |
| tree | 6ec22c2be92eff05f18e5919e747faab56e555ad /test/assert.c | |
| download | dged-2f4cb88d5c60f725323739300bb49dfa8923e7d5.tar.gz dged-2f4cb88d5c60f725323739300bb49dfa8923e7d5.tar.xz dged-2f4cb88d5c60f725323739300bb49dfa8923e7d5.zip | |
🎉 And so it begins
Diffstat (limited to 'test/assert.c')
| -rw-r--r-- | test/assert.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/assert.c b/test/assert.c new file mode 100644 index 0000000..b252d36 --- /dev/null +++ b/test/assert.c @@ -0,0 +1,20 @@ +#include "assert.h" + +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void assert(bool cond, const char *cond_str, const char *file, int line, + const char *msg) { + if (!cond) { + printf("\n%s:%d: assert failed (%s): %s\n", file, line, cond_str, msg); + raise(SIGABRT); + } +} + +void assert_streq(const char *left, const char *right, const char *file, + int line, const char *msg) { + assert(strcmp(left, right) == 0, "<left string> == <right string>", file, + line, msg); +} |
