From 2f4cb88d5c60f725323739300bb49dfa8923e7d5 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 2 Nov 2022 22:20:04 +0100 Subject: =?UTF-8?q?=F0=9F=8E=89=20And=20so=20it=20begins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/assert.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/assert.c (limited to 'test/assert.c') 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 +#include +#include +#include + +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, " == ", file, + line, msg); +} -- cgit v1.2.3