xaizek / stic (License: MIT) (since 2018-12-07)
Simple Tests In C with optional automatic test registration in C.
Commit 65736d3e07cfcc986d91007aa26e2a71ac3a3273

Print number of skipped tests in stic
This also required reformatting summary banner.
Author: xaizek
Author date (UTC): 2017-09-03 14:38
Committer name: xaizek
Committer date (UTC): 2017-09-03 17:16
Parent(s): f9c4a4d3978501b8b2490bb5e3117939eb7cae56
Signing key: 99DC5E4DB05F6BE2
Tree: 54c5469a1e8f113ec589659de62df4614f611700
File Lines added Lines deleted
src/stic.c 19 9
src/stic.h 6 1
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;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/stic

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/stic

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master