summaryrefslogtreecommitdiffstats
path: root/tests/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/main.c')
-rw-r--r--tests/main.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/main.c b/tests/main.c
index aef0583..81c2311 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -5,18 +5,29 @@
* Entry point for unit tests.
*/
-#include "prelude.h"
#include "tests.h"
-#include "bfstd.h"
+
#include "color.h"
+
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
+/** Result of the current test. */
+static thread_local bool pass;
+
+bool bfs_check_impl(bool result) {
+ pass &= result;
+ return result;
+}
+
+/** Unit test function type. */
+typedef void test_fn(void);
+
/**
- * Test context.
+ * Global test context.
*/
struct test_ctx {
/** Number of command line arguments. */
@@ -80,7 +91,10 @@ static bool should_run(const struct test_ctx *ctx, const char *test) {
/** Run a test if it's enabled. */
static void run_test(struct test_ctx *ctx, const char *test, test_fn *fn) {
if (should_run(ctx, test)) {
- if (fn()) {
+ pass = true;
+ fn();
+
+ if (pass) {
cfprintf(ctx->cout, "${grn}[PASS]${rs} ${bld}%s${rs}\n", test);
} else {
cfprintf(ctx->cout, "${red}[FAIL]${rs} ${bld}%s${rs}\n", test);
@@ -111,6 +125,7 @@ int main(int argc, char *argv[]) {
run_test(&ctx, "bfstd", check_bfstd);
run_test(&ctx, "bit", check_bit);
run_test(&ctx, "ioq", check_ioq);
+ run_test(&ctx, "list", check_list);
run_test(&ctx, "sighook", check_sighook);
run_test(&ctx, "trie", check_trie);
run_test(&ctx, "xspawn", check_xspawn);