File src/stic.c changed (mode: 100644) (index f6ce495..6ecabee) |
... |
... |
typedef struct |
70 |
70 |
|
|
71 |
71 |
static int stic_screen_width = 70; |
static int stic_screen_width = 70; |
72 |
72 |
static int sea_tests_run = 0; |
static int sea_tests_run = 0; |
|
73 |
|
static int sea_tests_failed = 0; |
73 |
74 |
static int sea_checks_passed = 0; |
static int sea_checks_passed = 0; |
74 |
75 |
static int sea_checks_failed = 0; |
static int sea_checks_failed = 0; |
75 |
76 |
static int stic_display_only = 0; |
static int stic_display_only = 0; |
|
... |
... |
static int test_had_output(void) |
185 |
186 |
void stic_simple_test_result_log(int passed, char* reason, const char* function, const char file[], unsigned int line) |
void stic_simple_test_result_log(int passed, char* reason, const char* function, const char file[], unsigned int line) |
186 |
187 |
{ |
{ |
187 |
188 |
static stic_void_void last_test; |
static stic_void_void last_test; |
|
189 |
|
static stic_void_void last_failed_test; |
188 |
190 |
|
|
189 |
191 |
const char *test_name = (stic_current_test == last_test) ? "" : stic_current_test_name; |
const char *test_name = (stic_current_test == last_test) ? "" : stic_current_test_name; |
190 |
192 |
|
|
|
... |
... |
void stic_simple_test_result_log(int passed, char* reason, const char* function, |
222 |
224 |
file, line, function, reason ); |
file, line, function, reason ); |
223 |
225 |
} |
} |
224 |
226 |
sea_checks_failed++; |
sea_checks_failed++; |
|
227 |
|
|
|
228 |
|
if (last_failed_test != stic_current_test) |
|
229 |
|
{ |
|
230 |
|
++sea_tests_failed; |
|
231 |
|
} |
|
232 |
|
last_failed_test = stic_current_test; |
|
233 |
|
|
225 |
234 |
last_test = stic_current_test; |
last_test = stic_current_test; |
226 |
235 |
} |
} |
227 |
236 |
else |
else |
|
... |
... |
int run_tests(stic_void_void tests) |
528 |
537 |
printf("\n"); |
printf("\n"); |
529 |
538 |
if (sea_checks_failed > 0) { |
if (sea_checks_failed > 0) { |
530 |
539 |
char s[100]; |
char s[100]; |
531 |
|
snprintf(s, sizeof(s), "Failed %d check%s", sea_checks_failed, |
|
532 |
|
sea_checks_failed == 1 ? "" : "s"); |
|
|
540 |
|
snprintf(s, sizeof(s), "%d CHECK%s IN %d TEST%s FAILED", |
|
541 |
|
sea_checks_failed, sea_checks_failed == 1 ? "" : "S", |
|
542 |
|
sea_tests_failed, sea_tests_failed == 1 ? "" : "S"); |
533 |
543 |
stic_header_printer(s, stic_screen_width, ' '); |
stic_header_printer(s, stic_screen_width, ' '); |
534 |
544 |
} |
} |
535 |
545 |
else |
else |
|
... |
... |
int run_tests(stic_void_void tests) |
538 |
548 |
snprintf(s, sizeof(s), "ALL TESTS PASSED"); |
snprintf(s, sizeof(s), "ALL TESTS PASSED"); |
539 |
549 |
stic_header_printer(s, stic_screen_width, ' '); |
stic_header_printer(s, stic_screen_width, ' '); |
540 |
550 |
} |
} |
541 |
|
sprintf(s,"%d test%s run", sea_tests_run, sea_tests_run == 1 ? "" : "s"); |
|
|
551 |
|
sprintf(s,"%d check%s in %d test%s", |
|
552 |
|
sea_checks_passed + sea_checks_failed, |
|
553 |
|
sea_checks_passed + sea_checks_failed == 1 ? "" : "s", |
|
554 |
|
sea_tests_run, sea_tests_run == 1 ? "" : "s"); |
542 |
555 |
stic_header_printer(s, stic_screen_width, ' '); |
stic_header_printer(s, stic_screen_width, ' '); |
543 |
556 |
|
|
544 |
557 |
if (end - start == 0) |
if (end - start == 0) |
545 |
558 |
{ |
{ |
546 |
|
sprintf(s,"in < 1 ms"); |
|
|
559 |
|
sprintf(s,"run in < 1 ms"); |
547 |
560 |
} |
} |
548 |
561 |
else |
else |
549 |
562 |
{ |
{ |
550 |
|
sprintf(s,"in %lu ms",end - start); |
|
|
563 |
|
sprintf(s,"run in %lu ms",end - start); |
551 |
564 |
} |
} |
552 |
565 |
|
|
553 |
566 |
stic_header_printer(s, stic_screen_width, ' '); |
stic_header_printer(s, stic_screen_width, ' '); |