Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 13 additions and 12 deletions. Show diff stats Hide diff stats

  1. 25  tests/minunit.h
25  tests/minunit.h
@@ -8,26 +8,27 @@
8 8
 
9 9
 #define mu_suite_start() char *message = NULL
10 10
 
  11
+#define mu_tested(test, message) do { printf("\e[31m\n%-10s : %s\e[0m",test, message); } while(0)
11 12
 #define mu_assert(test, message) if (!(test)) { log_err(message); return message; }
12  
-#define mu_run_test(test) debug("\n-----%s", " " #test);\
13  
-    message = test(); tests_run++; if (message) return message;
  13
+#define mu_run_test(test) do { message = test(); tests_run++; if (message) { debug("\n-----%s", " " #test);\
  14
+    tests_failed++; mu_tested(#test, message); } else { tests_passed++; } } while(0)
14 15
 
15 16
 #define RUN_TESTS(name) int main(int argc, char *argv[]) {\
16 17
     argc = 1;\
17  
-    debug("----- RUNNING: %s", argv[0]);\
18  
-    printf("----\nRUNNING: %s\n", argv[0]);\
19  
-    char *result = name();\
20  
-    if (result != 0) {\
21  
-        printf("FAILED: %s\n", result);\
  18
+    printf("----\nRUNNING: %s\n\e[0m", argv[0]);\
  19
+    name();\
  20
+    if (!(tests_failed)) {\
  21
+        printf("\n\n\e[32mALL TESTS PASSED\n\e[0m");\
22 22
     }\
23  
-    else {\
24  
-        printf("ALL TESTS PASSED\n");\
25  
-    }\
26  
-    printf("Tests run: %d\n", tests_run);\
27  
-    exit(result != 0);\
  23
+    printf("\n\n\e[33mTests run: %d\e[0m", tests_run);\
  24
+    printf("\n\e[32mTests passed: %d\e[0m", tests_passed);\
  25
+    printf("\n\e[31mTests failed: %d\n\n\e[0m", tests_failed);\
  26
+    exit(tests_failed);\
28 27
 }
29 28
 
30 29
 
31 30
 int tests_run;
  31
+int tests_failed;
  32
+int tests_passed;
32 33
 
33 34
 #endif

No commit comments for this range

Something went wrong with that request. Please try again.