consider calling run_test() with a null function as a pending test
This commit is contained in:
parent
94d6bc8cf9
commit
e41263adf0
10
9unit.c
10
9unit.c
@ -37,8 +37,16 @@ static void reindex(TestState *);
|
|||||||
void
|
void
|
||||||
run_test(TestState *s, TestResult (*t)(TestState *))
|
run_test(TestState *s, TestResult (*t)(TestState *))
|
||||||
{
|
{
|
||||||
if (!(s && t)) return;
|
if (!s) return;
|
||||||
s->run++;
|
s->run++;
|
||||||
|
|
||||||
|
// a null test function is a pending test
|
||||||
|
if (!t)
|
||||||
|
{
|
||||||
|
s->pending++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch ((*t)(s))
|
switch ((*t)(s))
|
||||||
{
|
{
|
||||||
case test_success:
|
case test_success:
|
||||||
|
@ -32,6 +32,7 @@ static void test_pass(TestState *);
|
|||||||
static void test_fail(TestState *);
|
static void test_fail(TestState *);
|
||||||
static void test_pend(TestState *);
|
static void test_pend(TestState *);
|
||||||
static void null_state(TestState *);
|
static void null_state(TestState *);
|
||||||
|
static void null_test(TestState *);
|
||||||
decl_test(always_passes);
|
decl_test(always_passes);
|
||||||
decl_test(always_fails);
|
decl_test(always_fails);
|
||||||
decl_test(always_pends);
|
decl_test(always_pends);
|
||||||
@ -46,6 +47,7 @@ test_run_test(TestState *s)
|
|||||||
test_fail(s);
|
test_fail(s);
|
||||||
test_pend(s);
|
test_pend(s);
|
||||||
null_state(s);
|
null_state(s);
|
||||||
|
null_test(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal Functions
|
// Internal Functions
|
||||||
@ -129,13 +131,40 @@ test_pend(TestState *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
null_state(TestState *s)
|
null_state(TestState *)
|
||||||
{
|
{
|
||||||
print("\tnull state\n");
|
print("\tnull state\n");
|
||||||
|
|
||||||
// make sure it doesn't crash
|
// make sure it doesn't crash
|
||||||
run_test(0, always_passes);
|
run_test(0, always_passes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
null_test(TestState *s)
|
||||||
|
{
|
||||||
|
TestState actual, expected;
|
||||||
|
print("\tnull test\n");
|
||||||
|
|
||||||
|
// expected value
|
||||||
|
memset(&expected, 0, sizeof(TestState));
|
||||||
|
expected.passed = 1;
|
||||||
|
expected.failed = 2;
|
||||||
|
expected.pending = 4;
|
||||||
|
expected.run = 7;
|
||||||
|
|
||||||
|
// actual value
|
||||||
|
mk_sample_state(&actual);
|
||||||
|
run_test(&actual, 0);
|
||||||
|
|
||||||
|
chk_TestState_eq(
|
||||||
|
s,
|
||||||
|
"\t\t",
|
||||||
|
"ERROR: run_test(): null_test:",
|
||||||
|
&actual,
|
||||||
|
&expected
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
decl_test(always_passes)
|
decl_test(always_passes)
|
||||||
{
|
{
|
||||||
return test_success;
|
return test_success;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user