made compare_ints() and compare_ptrs() accessible from outside util

This commit is contained in:
jlamothe 2023-11-10 22:44:42 +00:00
parent a14b11e853
commit 3309ac7aee
2 changed files with 52 additions and 52 deletions

View File

@ -110,22 +110,6 @@ static void compare_ptr(
const TestState *
);
// compare two ints
static void compare_ints(
TestState *,
const char *,
int,
int
);
// compare two pointers
static void compare_ptrs(
TestState *,
const char *,
void *,
void *
);
decl_test(compare_ints_test);
decl_test(compare_ptrs_test);
@ -159,6 +143,42 @@ compare_states(
compare_ptr(s, prefix, context, expected, actual);
}
void
compare_ints(
TestState *s,
const char *context,
int expected,
int actual
)
{
void *old_ptr = s->ptr;
CompareInts ci;
ci.context = context;
ci.expected = expected;
ci.actual = actual;
s->ptr = &ci;
run_test(s, compare_ints_test);
s->ptr = old_ptr;
}
void
compare_ptrs(
TestState *s,
const char *context,
void *expected,
void *actual
)
{
void *old_ptr = s->ptr;
ComparePtrs cp;
cp.context = context;
cp.expected = expected;
cp.actual = actual;
s->ptr = &cp;
run_test(s, compare_ptrs_test);
s->ptr = old_ptr;
}
// Local Functions
static void
@ -273,42 +293,6 @@ compare_ptr(
compare_ptrs(s, full_context, expected->ptr, actual->ptr);
}
static void
compare_ints(
TestState *s,
const char *context,
int expected,
int actual
)
{
void *old_ptr = s->ptr;
CompareInts ci;
ci.context = context;
ci.expected = expected;
ci.actual = actual;
s->ptr = &ci;
run_test(s, compare_ints_test);
s->ptr = old_ptr;
}
static void
compare_ptrs(
TestState *s,
const char *context,
void *expected,
void *actual
)
{
void *old_ptr = s->ptr;
ComparePtrs cp;
cp.context = context;
cp.expected = expected;
cp.actual = actual;
s->ptr = &cp;
run_test(s, compare_ptrs_test);
s->ptr = old_ptr;
}
def_test(compare_ints_test, s)
{
const CompareInts *ci = s->ptr;

View File

@ -36,4 +36,20 @@ extern void compare_states(
const TestState * // actual state
);
// compare two ints
extern void compare_ints(
TestState *,
const char *, // the error context
int, // the expected value
int // the actual value
);
// compare two pointers
extern void compare_ptrs(
TestState *,
const char *, // the error context
void *, // the expected value
void * // the actual value
);
//jl