implemented runTest

This commit is contained in:
jlamothe 2023-11-06 19:46:01 +00:00
parent b9c7fa84be
commit 519266e348
2 changed files with 25 additions and 6 deletions

27
9unit.c
View File

@ -25,12 +25,29 @@
void void
initTestState(TestState *s) initTestState(TestState *s)
{ {
if(s) if (!s) return;
s->run = 0;
s->success = 0;
s->failure = 0;
s->postponed = 0;
}
void
runTest(TestState *s, TestResult (*t)(void))
{
if (!(s && t)) return;
s->run++;
switch ((*t)())
{ {
s->run = 0; case test_success:
s->success = 0; s->success++;
s->failure = 0; break;
s->postponed = 0; case test_failure:
s->failure++;
break;
case test_postponed:
s->postponed++;
break;
} }
} }

View File

@ -31,9 +31,11 @@ typedef enum TestResult
{ {
test_success, test_success,
test_failure, test_failure,
test_pending test_postponed
} TestResult; } TestResult;
extern void initTestState(TestState *); extern void initTestState(TestState *);
extern void runTest(TestState *, TestResult (*)(void));
//jl //jl