summaryrefslogtreecommitdiff
path: root/test/assert.c
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2022-11-02 22:20:04 +0100
committerAlbert Cervin <albert@acervin.com>2022-11-16 23:33:49 +0100
commit2f4cb88d5c60f725323739300bb49dfa8923e7d5 (patch)
tree6ec22c2be92eff05f18e5919e747faab56e555ad /test/assert.c
downloaddged-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.c20
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);
+}