refactored single_test_context_with()
This commit is contained in:
parent
ad4abe68e0
commit
291d25927c
24
9unit.c
24
9unit.c
|
@ -57,9 +57,9 @@ struct TestContextWith
|
|||
void *val; // the value being passed in
|
||||
};
|
||||
|
||||
// data needed by single_test_context_with()
|
||||
struct SingleTestContextWith
|
||||
{
|
||||
void *ptr;
|
||||
TestResult (*test)(TestState *, void *);
|
||||
void *val;
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ static void display_context(TestState *);
|
|||
static void restore_context(TestState *, ContextData *);
|
||||
static void single_test_context_test(TestState *, void *);
|
||||
static void test_context_with_test(TestState *);
|
||||
static TestResult single_test_context_with_test(TestState *);
|
||||
static void single_test_context_with_test(TestState *, void *);
|
||||
static void check_value_test(TestState *, void *);
|
||||
|
||||
// Public Functions
|
||||
|
@ -241,14 +241,15 @@ single_test_context_with(
|
|||
void *val
|
||||
)
|
||||
{
|
||||
if (!s) return;
|
||||
if (!test) single_test_context(s, context, 0);
|
||||
SingleTestContextWith d;
|
||||
d.ptr = s->ptr;
|
||||
d.test = test;
|
||||
d.val = val;
|
||||
s->ptr = &d;
|
||||
single_test_context(s, context, single_test_context_with_test);
|
||||
test_context_with(
|
||||
s,
|
||||
context,
|
||||
single_test_context_with_test,
|
||||
&d
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -386,12 +387,11 @@ single_test_context_test(TestState *s, void *test)
|
|||
run_test(s, test);
|
||||
}
|
||||
|
||||
static TestResult
|
||||
single_test_context_with_test(TestState *s)
|
||||
static void
|
||||
single_test_context_with_test(TestState *s, void *ptr)
|
||||
{
|
||||
SingleTestContextWith *d = s->ptr;
|
||||
s->ptr = d->ptr;
|
||||
return (*d->test)(s, d->val);
|
||||
SingleTestContextWith *d = ptr;
|
||||
run_test_with(s, d->test, d->val);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue
Block a user