restructured library to hide struct initialization

This commit is contained in:
jlamothe
2023-11-06 23:23:18 +00:00
parent e3037f3f3f
commit 870f1b619b
2 changed files with 51 additions and 25 deletions

37
9unit.h
View File

@@ -19,34 +19,47 @@
*/
// Tracks information about the tests being run.
typedef struct TestState
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.
struct TestState
{
int run; // number of tests run
int passed; // number of successful tests
int failed; // number of failed tests
int postponed; // number of postponed tests
} TestState;
TestLogEntry *first_log; // the first log entry
TestLogEntry *last_log; //the last log entry
};
struct TestLogEntry
{
char *text; // the entry text
TestLogEntry *next; // points to the next entry
};
// Possible results of running a single test
typedef enum TestResult
{
test_success,
test_failure,
test_postponed
test_success, // the test succeeded
test_failure, // the test failed
test_postponed // the test was postponed
} TestResult;
// Initializes a TestState value
extern void initTestState(TestState *);
// Runs a single test
extern void runTest(
extern void run_test(
TestState *, // the TestState data
TestResult (*)(void) // the test to run
TestResult (*)(TestState *) // the test to run
);
// Runs multiple tests, displaying a summary at the end
extern void runTests(
// function that runs the tests and updates the provided TestState
extern void run_tests(
// runs the tests and updates a provided TestState
void (*)(TestState *)
);