File src/stic.c changed (mode: 100644) (index 6ecabee..3a4e61e) |
... |
... |
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_skipped = 0; |
73 |
74 |
static int sea_tests_failed = 0; |
static int sea_tests_failed = 0; |
74 |
75 |
static int sea_checks_passed = 0; |
static int sea_checks_passed = 0; |
75 |
76 |
static int sea_checks_failed = 0; |
static int sea_checks_failed = 0; |
|
... |
... |
void stic_suite_setup( void ) |
125 |
126 |
if(stic_suite_setup_func != 0) stic_suite_setup_func(); |
if(stic_suite_setup_func != 0) stic_suite_setup_func(); |
126 |
127 |
} |
} |
127 |
128 |
|
|
|
129 |
|
void stic_skip_test(const char fixture[], const char test[]) |
|
130 |
|
{ |
|
131 |
|
sea_tests_skipped++; |
|
132 |
|
} |
|
133 |
|
|
128 |
134 |
int stic_positive_predicate( void ) |
int stic_positive_predicate( void ) |
129 |
135 |
{ |
{ |
130 |
136 |
return 1; |
return 1; |
|
... |
... |
int run_tests(stic_void_void tests) |
520 |
526 |
unsigned long end; |
unsigned long end; |
521 |
527 |
unsigned long start = GetTickCount(); |
unsigned long start = GetTickCount(); |
522 |
528 |
char version[40]; |
char version[40]; |
523 |
|
char s[40]; |
|
|
529 |
|
char s[100]; |
|
530 |
|
char time[40]; |
524 |
531 |
tests(); |
tests(); |
525 |
532 |
end = GetTickCount(); |
end = GetTickCount(); |
526 |
533 |
|
|
|
... |
... |
int run_tests(stic_void_void tests) |
536 |
543 |
stic_header_printer(version, stic_screen_width, '='); |
stic_header_printer(version, stic_screen_width, '='); |
537 |
544 |
printf("\n"); |
printf("\n"); |
538 |
545 |
if (sea_checks_failed > 0) { |
if (sea_checks_failed > 0) { |
539 |
|
char s[100]; |
|
540 |
546 |
snprintf(s, sizeof(s), "%d CHECK%s IN %d TEST%s FAILED", |
snprintf(s, sizeof(s), "%d CHECK%s IN %d TEST%s FAILED", |
541 |
547 |
sea_checks_failed, sea_checks_failed == 1 ? "" : "S", |
sea_checks_failed, sea_checks_failed == 1 ? "" : "S", |
542 |
548 |
sea_tests_failed, sea_tests_failed == 1 ? "" : "S"); |
sea_tests_failed, sea_tests_failed == 1 ? "" : "S"); |
|
... |
... |
int run_tests(stic_void_void tests) |
544 |
550 |
} |
} |
545 |
551 |
else |
else |
546 |
552 |
{ |
{ |
547 |
|
char s[100]; |
|
548 |
553 |
snprintf(s, sizeof(s), "ALL TESTS PASSED"); |
snprintf(s, sizeof(s), "ALL TESTS PASSED"); |
549 |
554 |
stic_header_printer(s, stic_screen_width, ' '); |
stic_header_printer(s, stic_screen_width, ' '); |
550 |
555 |
} |
} |
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"); |
|
|
556 |
|
|
|
557 |
|
memset(s, '-', strlen(s)); |
555 |
558 |
stic_header_printer(s, stic_screen_width, ' '); |
stic_header_printer(s, stic_screen_width, ' '); |
556 |
559 |
|
|
557 |
560 |
if (end - start == 0) |
if (end - start == 0) |
558 |
561 |
{ |
{ |
559 |
|
sprintf(s,"run in < 1 ms"); |
|
|
562 |
|
sprintf(time,"< 1 ms"); |
560 |
563 |
} |
} |
561 |
564 |
else |
else |
562 |
565 |
{ |
{ |
563 |
|
sprintf(s,"run in %lu ms",end - start); |
|
|
566 |
|
sprintf(time,"%lu ms",end - start); |
564 |
567 |
} |
} |
565 |
568 |
|
|
|
569 |
|
sprintf(s,"%d check%s :: %d run test%s :: %d skipped test%s :: %s", |
|
570 |
|
sea_checks_passed + sea_checks_failed, |
|
571 |
|
sea_checks_passed + sea_checks_failed == 1 ? "" : "s", |
|
572 |
|
sea_tests_run, sea_tests_run == 1 ? "" : "s", |
|
573 |
|
sea_tests_skipped, sea_tests_skipped == 1 ? "" : "s", |
|
574 |
|
time); |
566 |
575 |
stic_header_printer(s, stic_screen_width, ' '); |
stic_header_printer(s, stic_screen_width, ' '); |
|
576 |
|
|
567 |
577 |
printf("\n"); |
printf("\n"); |
568 |
578 |
stic_header_printer("", stic_screen_width, '='); |
stic_header_printer("", stic_screen_width, '='); |
569 |
579 |
|
|
File src/stic.h changed (mode: 100644) (index 89b2d13..63c7141) |
... |
... |
void stic_assert_string_doesnt_contain(const char* expected, const char* actual, |
46 |
46 |
int stic_should_run(const char fixture[], const char test[]); |
int stic_should_run(const char fixture[], const char test[]); |
47 |
47 |
void stic_before_run( char* fixture, char* test); |
void stic_before_run( char* fixture, char* test); |
48 |
48 |
void stic_run_test(const char fixture[], const char test[]); |
void stic_run_test(const char fixture[], const char test[]); |
|
49 |
|
void stic_skip_test(const char fixture[], const char test[]); |
49 |
50 |
void stic_setup( void ); |
void stic_setup( void ); |
50 |
51 |
void stic_teardown( void ); |
void stic_teardown( void ); |
51 |
52 |
void stic_suite_teardown( void ); |
void stic_suite_teardown( void ); |
|
... |
... |
static void stic_fixture(void) |
321 |
322 |
{ |
{ |
322 |
323 |
struct stic_test_data *td = *test_data[i]; |
struct stic_test_data *td = *test_data[i]; |
323 |
324 |
if(td == NULL) continue; |
if(td == NULL) continue; |
324 |
|
if(td->p != NULL && !td->p()) continue; |
|
|
325 |
|
if(td->p != NULL && !td->p()) |
|
326 |
|
{ |
|
327 |
|
stic_skip_test(fixture_name, td->n); |
|
328 |
|
continue; |
|
329 |
|
} |
325 |
330 |
if(!stic_should_run(fixture_name, td->n)) continue; |
if(!stic_should_run(fixture_name, td->n)) continue; |
326 |
331 |
|
|
327 |
332 |
stic_current_test_name = td->n; |
stic_current_test_name = td->n; |