minor edits and testing of initial TestState value

This commit is contained in:
jlamothe
2023-11-07 23:44:53 +00:00
parent 9f26846a3d
commit e9ed464b60
3 changed files with 124 additions and 10 deletions

14
9unit.c
View File

@@ -46,8 +46,8 @@ run_test(TestState *s, TestResult (*t)(TestState *))
case test_failure:
s->failed++;
break;
case test_postponed:
s->postponed++;
case test_pending:
s->pending++;
break;
default:
exits("test returned an invalid response");
@@ -57,7 +57,7 @@ run_test(TestState *s, TestResult (*t)(TestState *))
void
run_tests(void (*tests)(TestState *))
{
if(!tests) return;
if (!tests) return;
TestState s;
init_TestState(&s);
(*tests)(&s);
@@ -65,12 +65,13 @@ run_tests(void (*tests)(TestState *))
printf("Tests run: %d\n", s.run);
printf("Tests passed: %d\n", s.passed);
printf("Tests failed: %d\n", s.failed);
printf("Tests postponed: %d\n", s.postponed);
printf("Tests pending: %d\n", s.pending);
clear_log(&s);
if (s.failed) exits("test(s) failed");
}
void
append_log(TestState *s, const char *msg)
append_test_log(TestState *s, const char *msg)
{
if (!(s && msg)) return;
@@ -108,9 +109,10 @@ init_TestState(TestState *s)
s->run = 0;
s->passed = 0;
s->failed = 0;
s->postponed = 0;
s->pending = 0;
s->first_log = 0;
s->last_log = 0;
s->ptr = 0;
}
static void