summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ctype.c2
-rw-r--r--locale.c2
-rw-r--r--test.c24
-rw-r--r--test.h1
4 files changed, 25 insertions, 4 deletions
diff --git a/ctype.c b/ctype.c
index cb38da4..94de005 100644
--- a/ctype.c
+++ b/ctype.c
@@ -81,4 +81,6 @@ void test_ctype(void)
test_ctype_conversion(tolower, UPPER, LOWER);
test_ctype_conversion(toupper, LOWER, UPPER);
+
+ testing_end();
}
diff --git a/locale.c b/locale.c
index 629ef0b..b6d48ed 100644
--- a/locale.c
+++ b/locale.c
@@ -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();
}
diff --git a/test.c b/test.c
index 2d25648..2750ec3 100644
--- a/test.c
+++ b/test.c
@@ -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);
diff --git a/test.h b/test.h
index 7fa1efe..f6566b9 100644
--- a/test.h
+++ b/test.h
@@ -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)