added context info to TestState
This commit is contained in:
79
test/util.c
79
test/util.c
@@ -110,6 +110,33 @@ static void chk_TestState_ptr_eq(
|
||||
const TestState *
|
||||
);
|
||||
|
||||
// compare the context value of two states
|
||||
static void chk_TestState_context_eq(
|
||||
TestState *,
|
||||
const char *,
|
||||
const char *,
|
||||
const TestState *,
|
||||
const TestState *
|
||||
);
|
||||
|
||||
// compare the full_context value of two states
|
||||
static void chk_TestState_full_context_eq(
|
||||
TestState *,
|
||||
const char *,
|
||||
const char *,
|
||||
const TestState *,
|
||||
const TestState *
|
||||
);
|
||||
|
||||
// compare the depth value of two states
|
||||
static void chk_TestState_depth_eq(
|
||||
TestState *,
|
||||
const char *,
|
||||
const char *,
|
||||
const TestState *,
|
||||
const TestState *
|
||||
);
|
||||
|
||||
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
|
||||
@@ -143,6 +170,9 @@ chk_TestState_eq(
|
||||
chk_TestState_first_log_eq(s, prefix, context, actual, expected);
|
||||
chk_TestState_last_log_eq(s, prefix, context, actual, expected);
|
||||
chk_TestState_ptr_eq(s, prefix, context, actual, expected);
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -331,6 +361,54 @@ chk_TestState_ptr_eq(
|
||||
chk_ptr_eq(s, full_context, actual->ptr, expected->ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
chk_TestState_context_eq(
|
||||
TestState *s,
|
||||
const char *prefix,
|
||||
const char *context,
|
||||
const TestState *actual,
|
||||
const TestState *expected
|
||||
)
|
||||
{
|
||||
char full_context[STR_BUF_SIZE];
|
||||
print(prefix);
|
||||
print("context\n");
|
||||
snprintf(full_context, STR_BUF_SIZE, "%s context:", context);
|
||||
chk_str_eq(s, full_context, actual->context, expected->context);
|
||||
}
|
||||
|
||||
static void
|
||||
chk_TestState_full_context_eq(
|
||||
TestState *s,
|
||||
const char *prefix,
|
||||
const char *context,
|
||||
const TestState *actual,
|
||||
const TestState *expected
|
||||
)
|
||||
{
|
||||
char full_context[STR_BUF_SIZE];
|
||||
print(prefix);
|
||||
print("full_context\n");
|
||||
snprintf(full_context, STR_BUF_SIZE, "%s full_context:", context);
|
||||
chk_str_eq(s, full_context, actual->full_context, expected->full_context);
|
||||
}
|
||||
|
||||
static void
|
||||
chk_TestState_depth_eq(
|
||||
TestState *s,
|
||||
const char *prefix,
|
||||
const char *context,
|
||||
const TestState *actual,
|
||||
const TestState *expected
|
||||
)
|
||||
{
|
||||
char full_context[STR_BUF_SIZE];
|
||||
print(prefix);
|
||||
print("depth\n");
|
||||
snprintf(full_context, STR_BUF_SIZE, "%s depth:", context);
|
||||
chk_int_eq(s, full_context, actual->depth, expected->depth);
|
||||
}
|
||||
|
||||
def_test(chk_int_eq_test, s)
|
||||
{
|
||||
const CompareInts *ci = s->ptr;
|
||||
@@ -371,6 +449,7 @@ def_test(chk_ptr_ne_test, s)
|
||||
def_test(chk_str_eq_test, s)
|
||||
{
|
||||
const ComparePtrs *cp = s->ptr;
|
||||
if (!cp->chk_val && !cp->ref_val) return test_success;
|
||||
if (!strcmp(cp->chk_val, cp->ref_val)) return test_success;
|
||||
char str[STR_BUF_SIZE];
|
||||
append_test_log(s, cp->context);
|
||||
|
||||
Reference in New Issue
Block a user