Compare commits
No commits in common. "55926ec0d8e5c6190b87c99e067f46fa51d2868a" and "291d25927c970f4e9e2d14a2d79a504cfbcdb528" have entirely different histories.
55926ec0d8
...
291d25927c
35
9unit.c
35
9unit.c
|
@ -28,7 +28,6 @@
|
|||
// Internal Types
|
||||
|
||||
typedef struct RunTestWith RunTestWith;
|
||||
typedef struct RunTestCompare RunTestCompare;
|
||||
typedef struct ContextData ContextData;
|
||||
typedef struct TestContextWith TestContextWith;
|
||||
typedef struct SingleTestContextWith SingleTestContextWith;
|
||||
|
@ -42,14 +41,6 @@ struct RunTestWith
|
|||
void *val; // the value passed in
|
||||
};
|
||||
|
||||
// data needed by run_test_compare()
|
||||
struct RunTestCompare
|
||||
{
|
||||
TestResult (*test)(TestState *, void *, void *);
|
||||
void *val1;
|
||||
void *val2;
|
||||
};
|
||||
|
||||
struct ContextData
|
||||
{
|
||||
const char *old_c; // previous context
|
||||
|
@ -88,7 +79,6 @@ static void clear_log(TestState *);
|
|||
static void reindex(TestState *);
|
||||
static void report(const char *);
|
||||
static TestResult run_test_with_test(TestState *);
|
||||
static TestResult run_test_compare_test(TestState *, void *);
|
||||
static void build_new_context(TestState *, ContextData *);
|
||||
static void display_context(TestState *);
|
||||
static void restore_context(TestState *, ContextData *);
|
||||
|
@ -149,21 +139,6 @@ run_test_with(
|
|||
run_test(s, run_test_with_test);
|
||||
}
|
||||
|
||||
void
|
||||
run_test_compare(
|
||||
TestState *s,
|
||||
TestResult (*test)(TestState *, void *, void *),
|
||||
void *val1,
|
||||
void *val2
|
||||
)
|
||||
{
|
||||
RunTestCompare d;
|
||||
d.test = test;
|
||||
d.val1 = val1;
|
||||
d.val2 = val2;
|
||||
run_test_with(s, run_test_compare_test, &d);
|
||||
}
|
||||
|
||||
void
|
||||
run_tests(void (*tests)(TestState *))
|
||||
{
|
||||
|
@ -398,16 +373,6 @@ run_test_with_test(TestState *s)
|
|||
return (*d->test)(s, d->val);
|
||||
}
|
||||
|
||||
static TestResult
|
||||
run_test_compare_test(
|
||||
TestState *s,
|
||||
void *ptr
|
||||
)
|
||||
{
|
||||
RunTestCompare *d = ptr;
|
||||
return (*d->test)(s, d->val1, d->val2);
|
||||
}
|
||||
|
||||
static void
|
||||
test_context_with_test(TestState *s)
|
||||
{
|
||||
|
|
33
9unit.h
33
9unit.h
|
@ -21,14 +21,15 @@
|
|||
|
||||
// Types & Structs
|
||||
|
||||
// Tracks information about the tests being run.
|
||||
typedef struct TestState TestState;
|
||||
|
||||
// Defines a log entry in a TestState struct
|
||||
typedef struct TestLogEntry TestLogEntry;
|
||||
|
||||
// The following structures will typically be maintained by the
|
||||
// testing framework. You shouldn't need to concern yourself with
|
||||
// them.
|
||||
|
||||
typedef struct TestState TestState;
|
||||
typedef struct TestLogEntry TestLogEntry;
|
||||
|
||||
// Tracks information about the tests being run.
|
||||
struct TestState
|
||||
{
|
||||
int run; // number of tests run
|
||||
|
@ -44,7 +45,6 @@ struct TestState
|
|||
void (*report)(const char *); // prints a string immediately
|
||||
};
|
||||
|
||||
// Defines a log entry in a TestState struct
|
||||
struct TestLogEntry
|
||||
{
|
||||
char *text; // the entry text
|
||||
|
@ -74,25 +74,12 @@ extern void run_test_with(
|
|||
void * // the value to pass in
|
||||
);
|
||||
|
||||
// Runs a single test passing in two values to be compared
|
||||
extern void run_test_compare(
|
||||
TestState *, // the current state
|
||||
|
||||
// the test to be run
|
||||
TestResult (*test)(
|
||||
TestState *, // the current state
|
||||
void *, // the first value
|
||||
void * // the second value
|
||||
),
|
||||
|
||||
void *, // the first value
|
||||
void * // the second value
|
||||
// Runs multiple tests, displaying a summary at the end
|
||||
extern void run_tests(
|
||||
// runs the tests and updates a provided TestState
|
||||
void (*)(TestState *)
|
||||
);
|
||||
|
||||
// Creates an initial TestState, passes it to the supplied function,
|
||||
// and displays the resulting log and summary
|
||||
extern void run_tests(void (*)(TestState *));
|
||||
|
||||
// Adds an entry to the log that is displayed after the tests have
|
||||
// completed
|
||||
extern void append_test_log(
|
||||
|
|
Loading…
Reference in New Issue
Block a user