made compare_ints() and compare_ptrs() accessible from outside util
This commit is contained in:
parent
a14b11e853
commit
3309ac7aee
88
test/util.c
88
test/util.c
@ -110,22 +110,6 @@ static void compare_ptr(
|
|||||||
const TestState *
|
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_ints_test);
|
||||||
decl_test(compare_ptrs_test);
|
decl_test(compare_ptrs_test);
|
||||||
|
|
||||||
@ -159,6 +143,42 @@ compare_states(
|
|||||||
compare_ptr(s, prefix, context, expected, actual);
|
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
|
// Local Functions
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -273,42 +293,6 @@ compare_ptr(
|
|||||||
compare_ptrs(s, full_context, expected->ptr, actual->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)
|
def_test(compare_ints_test, s)
|
||||||
{
|
{
|
||||||
const CompareInts *ci = s->ptr;
|
const CompareInts *ci = s->ptr;
|
||||||
|
16
test/util.h
16
test/util.h
@ -36,4 +36,20 @@ extern void compare_states(
|
|||||||
const TestState * // actual state
|
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
|
//jl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user