Skip to content

Commit

Permalink
Merge pull request #3 from SGmuwa/codepleaIssues2
Browse files Browse the repository at this point in the history
Change output format
  • Loading branch information
codeplea committed Mar 3, 2021
2 parents c79fc75 + 97edb92 commit 630f9ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ There is a [Node.js port here](https://github.com/codeplea/minctest-node) and a

That produces the following output:

test1 pass: 1 fail: 0 0ms
test2 pass: 3 fail: 0 1ms
test1:
-- pass: 1 fail: 0 time: 12ms
test2:
-- pass: 3 fail: 0 time: 0ms
ALL TESTS PASSED (4/4)


Expand Down
18 changes: 9 additions & 9 deletions minctest.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,30 @@

/* Track the number of passes, fails. */
/* NB this is made for all tests to be in one file. */
static int ltests = 0;
static int lfails = 0;
static size_t ltests = 0;
static size_t lfails = 0;


/* Display the test results. */
#define lresults() do {\
if (lfails == 0) {\
printf("ALL TESTS PASSED (%d/%d)\n", ltests, ltests);\
printf("ALL TESTS PASSED (%zu/%zu)\n", ltests, ltests);\
} else {\
printf("SOME TESTS FAILED (%d/%d)\n", ltests-lfails, ltests);\
printf("SOME TESTS FAILED (%zu/%zu)\n", ltests-lfails, ltests);\
}\
} while (0)


/* Run a test. Name can be any string to print out, test is the function name to call. */
#define lrun(name, test) do {\
const int ts = ltests;\
const int fs = lfails;\
const size_t ts = ltests;\
const size_t fs = lfails;\
const clock_t start = clock();\
printf("\t%-14s", name);\
printf("\t%s:\n", name);\
test();\
printf("pass:%2d fail:%2d %4dms\n",\
printf("\t -- pass: %-20zu fail: %-20zu time: %ldms\n",\
(ltests-ts)-(lfails-fs), lfails-fs,\
(int)((clock() - start) * 1000 / CLOCKS_PER_SEC));\
(long)((clock() - start) * 1000 / CLOCKS_PER_SEC));\
} while (0)


Expand Down

0 comments on commit 630f9ae

Please sign in to comment.