refactored single_test_context()
This commit is contained in:
parent
8138f59fef
commit
1c4fb1e87d
24
9unit.c
24
9unit.c
|
@ -29,7 +29,6 @@
|
|||
|
||||
typedef struct RunTestWith RunTestWith;
|
||||
typedef struct ContextData ContextData;
|
||||
typedef struct SingleTestContext SingleTestContext;
|
||||
typedef struct TestContextWith TestContextWith;
|
||||
typedef struct SingleTestContextWith SingleTestContextWith;
|
||||
typedef struct CheckValue CheckValue;
|
||||
|
@ -50,12 +49,6 @@ struct ContextData
|
|||
char *new_fc; // new full context
|
||||
};
|
||||
|
||||
struct SingleTestContext
|
||||
{
|
||||
void *ptr; // the state's previous ptr value
|
||||
TestResult (*test)(TestState *); // the test to run
|
||||
};
|
||||
|
||||
struct TestContextWith
|
||||
{
|
||||
void *ptr; // state's original ptr value
|
||||
|
@ -88,7 +81,7 @@ static TestResult run_test_with_test(TestState *);
|
|||
static void build_new_context(TestState *, ContextData *);
|
||||
static void display_context(TestState *);
|
||||
static void restore_context(TestState *, ContextData *);
|
||||
static void single_test_context_test(TestState *);
|
||||
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 check_value_test(TestState *, void *);
|
||||
|
@ -215,16 +208,11 @@ test_context(
|
|||
void
|
||||
single_test_context(
|
||||
TestState *s,
|
||||
const char *label,
|
||||
const char *context,
|
||||
TestResult (*test)(TestState *)
|
||||
)
|
||||
{
|
||||
if (!s) return;
|
||||
SingleTestContext d;
|
||||
d.ptr = s->ptr;
|
||||
d.test = test;
|
||||
s->ptr = &d;
|
||||
test_context(s, label, single_test_context_test);
|
||||
test_context_with(s, context, single_test_context_test, test);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -384,11 +372,9 @@ run_test_with_test(TestState *s)
|
|||
}
|
||||
|
||||
static void
|
||||
single_test_context_test(TestState *s)
|
||||
single_test_context_test(TestState *s, void *test)
|
||||
{
|
||||
SingleTestContext *d = s->ptr;
|
||||
s->ptr = d->ptr;
|
||||
run_test(s, d->test);
|
||||
run_test(s, test);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue
Block a user