diff options
-rw-r--r-- | ctype.c | 2 | ||||
-rw-r--r-- | locale.c | 2 | ||||
-rw-r--r-- | test.c | 24 | ||||
-rw-r--r-- | test.h | 1 |
4 files changed, 25 insertions, 4 deletions
@@ -81,4 +81,6 @@ void test_ctype(void) test_ctype_conversion(tolower, UPPER, LOWER); test_ctype_conversion(toupper, LOWER, UPPER); + + testing_end(); } @@ -72,4 +72,6 @@ void test_locale(void) test_int_equals(lc->n_sep_by_space, CHAR_MAX); test_int_equals(lc->p_sign_posn, CHAR_MAX); test_int_equals(lc->n_sign_posn, CHAR_MAX); + + testing_end(); } @@ -1,6 +1,9 @@ #include <stdio.h> #include <stdarg.h> +static int passed; +static int failed; + typedef enum { DEFAULT = 39, RED = 31, @@ -21,9 +24,14 @@ static void print_result(int success, const char *format, ...) Color color = GREEN; char indicator = '+'; - if (!success) { - color = RED; - indicator = '!'; + if (success) { + set_output_color(GREEN); + printf("+ "); + passed++; + } else { + set_output_color(RED); + printf("- "); + failed++; } set_output_color(color); @@ -33,7 +41,7 @@ static void print_result(int success, const char *format, ...) vprintf(format, ap); va_end(ap); - printf("\n"); + printf("%c", success ? '\r' : '\n'); set_output_color(DEFAULT); } @@ -46,6 +54,14 @@ void testing_header(const char *header) printf("\n"); } +void testing_end(void) +{ + printf("%d tests passed, %d tests failed\n", passed, failed); + + passed = 0; + failed = 0; +} + void testing_comment(const char *comment) { printf("- %s\n", comment); @@ -1,5 +1,6 @@ void testing_header(const char *); void testing_comment(const char*); +void testing_end(void); void test_int_equals_imp(const char*, int, int); #define test_int_equals(expression, expected) test_int_equals_imp(#expression, expression, expected) |