created overridable report() function to be used in place of print()
This commit is contained in:
36
test/util.c
36
test/util.c
@@ -137,6 +137,18 @@ static void chk_TestState_depth_eq(
|
||||
const TestState *
|
||||
);
|
||||
|
||||
// compare the report pointer of two states
|
||||
static void chk_TestState_report_eq(
|
||||
TestState *,
|
||||
const char *,
|
||||
const char *,
|
||||
const TestState *,
|
||||
const TestState *
|
||||
);
|
||||
|
||||
// discard report data
|
||||
static void report(const char *);
|
||||
|
||||
decl_test(chk_int_eq_test); // ensure ints are equal
|
||||
decl_test(chk_ptr_eq_test); // ensure pointers are equal
|
||||
decl_test(chk_ptr_ne_test); // ensure pointers are not equal
|
||||
@@ -152,6 +164,7 @@ mk_sample_state(TestState *s)
|
||||
s->failed = 2;
|
||||
s->pending = 3;
|
||||
s->run = 6;
|
||||
s->report = report;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -173,6 +186,7 @@ chk_TestState_eq(
|
||||
chk_TestState_context_eq(s, prefix, context, actual, expected);
|
||||
chk_TestState_full_context_eq(s, prefix, context, actual, expected);
|
||||
chk_TestState_depth_eq(s, prefix, context, actual, expected);
|
||||
chk_TestState_report_eq(s, prefix, context, actual, expected);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -409,6 +423,22 @@ chk_TestState_depth_eq(
|
||||
chk_int_eq(s, full_context, actual->depth, expected->depth);
|
||||
}
|
||||
|
||||
static void
|
||||
chk_TestState_report_eq(
|
||||
TestState *s,
|
||||
const char *prefix,
|
||||
const char *context,
|
||||
const TestState *actual,
|
||||
const TestState *expected
|
||||
)
|
||||
{
|
||||
char full_context[STR_BUF_SIZE];
|
||||
print(prefix);
|
||||
print("report()\n");
|
||||
snprintf(full_context, STR_BUF_SIZE, "%s report():", context);
|
||||
chk_ptr_eq(s, full_context, actual->report, expected->report);
|
||||
}
|
||||
|
||||
def_test(chk_int_eq_test, s)
|
||||
{
|
||||
const CompareInts *ci = s->ptr;
|
||||
@@ -460,4 +490,10 @@ def_test(chk_str_eq_test, s)
|
||||
return test_failure;
|
||||
}
|
||||
|
||||
static void
|
||||
report(const char *)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//jl
|
||||
|
||||
Reference in New Issue
Block a user