implemented runTest
This commit is contained in:
parent
b9c7fa84be
commit
519266e348
27
9unit.c
27
9unit.c
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
9unit.h
4
9unit.h
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user