From 7f0fc08c05142f9f70cb05a4b1b1d6f0b1a3279b Mon Sep 17 00:00:00 2001 From: axtloss Date: Thu, 17 Oct 2024 02:39:27 +0200 Subject: Add strfmt --- tests/driver.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tests/driver.c') diff --git a/tests/driver.c b/tests/driver.c index d3739b5..4d998b8 100644 --- a/tests/driver.c +++ b/tests/driver.c @@ -6,9 +6,8 @@ #include "../src/extlib.h" #include "test_driver.h" -const char* success = "\033[1;32m"; -const char* fail = " \033[1;31m"; -const char *reset = "\033[0m"; +char* success; +char* fail; int tests_count; struct test_t** registered_tests; @@ -19,9 +18,9 @@ test_runner (struct test_t *test, int n) printf ("Test Case %d: %s -- %s\n", n, test->test_name, test->test_desc); int test_result = test->test_func(); if (test_result == 0) - printf ("Test Case %d: %s -- %sSUCCESS%s\n\n", n, test->test_name, success, reset); + printf ("Test Case %d: %s -- %s\n\n", n, test->test_name, success); else - printf ("Test Case %d: %s -- %sFAIL %d%s\n\n", n, test->test_name, fail, test_result, reset); + printf ("Test Case %d: %s -- %s %d\n\n", n, test->test_name, fail, test_result); } void @@ -36,6 +35,9 @@ register_test (struct test_t *test) int main (int argc, char *argv[]) { + success = strfmt("SUCCESS", (struct style) {.color = GREEN, .background = false, .styles = BOLD|UNDERLINE}); + fail = strfmt("FAIL", (struct style) {.color = RED, .background = false, .styles = BOLD|UNDERLINE}); + registered_tests = malloc (8); tests_entrypoint(); for (int i = 0; i < tests_count; i++) -- cgit v1.2.3