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

Display number of failed tests

Also update summary format to be consistent and always include both
checks and tests.

Author: xaizek
Author date (UTC): 2017-09-03 12:38
Committer: xaizek
Commit date (UTC): 2017-09-03 17:16
Tree: cd0eb1a8445562ac439ae1e28e092060069ea01e
Parents: 64f1750c84407aca512295b8276cc326087f0d64
Signing key: 99DC5E4DB05F6BE2
File Lines added Lines deleted
src/stic.c 18 5

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, ' ');
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