Added rudimentary test ordering, for the Init and Uninit tests.
This commit is contained in:
parent
1b046e763b
commit
59b449b920
|
@ -2,11 +2,11 @@
|
|||
#include "../ui.h"
|
||||
#include "testing.h"
|
||||
|
||||
testingTest(Init)
|
||||
testingTestBefore(Init)
|
||||
{
|
||||
}
|
||||
|
||||
testingTest(Uninit)
|
||||
testingTestAfter(Uninit)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ struct testingT {
|
|||
|
||||
static testingT *tests = NULL;
|
||||
static testingT *testsTail = NULL;
|
||||
static testingT *testsBefore = NULL;
|
||||
static testingT *testsBeforeTail = NULL;
|
||||
static testingT *testsAfter = NULL;
|
||||
static testingT *testsAfterTail = NULL;
|
||||
|
||||
static testingT *newTest(const char *name, void (*f)(testingT *), testingT *prev)
|
||||
{
|
||||
|
@ -55,6 +59,26 @@ void testingprivRegisterTest(const char *name, void (*f)(testingT *))
|
|||
tests = t;
|
||||
}
|
||||
|
||||
void testingprivRegisterTestBefore(const char *name, void (*f)(testingT *))
|
||||
{
|
||||
testingT *t;
|
||||
|
||||
t = newTest(name, f, testsBeforeTail);
|
||||
testsBeforeTail = t;
|
||||
if (testsBefore == NULL)
|
||||
testsBefore = t;
|
||||
}
|
||||
|
||||
void testingprivRegisterTestAfter(const char *name, void (*f)(testingT *))
|
||||
{
|
||||
testingT *t;
|
||||
|
||||
t = newTest(name, f, testsAfterTail);
|
||||
testsAfterTail = t;
|
||||
if (testsAfter == NULL)
|
||||
testsAfter = t;
|
||||
}
|
||||
|
||||
static void runDefers(testingT *t)
|
||||
{
|
||||
struct defer *d;
|
||||
|
@ -99,7 +123,9 @@ int testingMain(void)
|
|||
}
|
||||
|
||||
anyFailed = 0;
|
||||
runTestSet(testsBefore, &anyFailed);
|
||||
runTestSet(tests, &anyFailed);
|
||||
runTestSet(testsAfter, &anyFailed);
|
||||
if (anyFailed) {
|
||||
printf("FAIL\n");
|
||||
return 1;
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
|
||||
#define testingTest(Name) \
|
||||
testingprivMk(Test ## Name, testingT, t, testingprivRegisterTest)
|
||||
#define testingTestBefore(Name) \
|
||||
testingprivMk(Test ## Name, testingT, t, testingprivRegisterTestBefore)
|
||||
#define testingTestAfter(Name) \
|
||||
testingprivMk(Test ## Name, testingT, t, testingprivRegisterTestAfter)
|
||||
|
||||
extern int testingMain(void);
|
||||
|
||||
|
@ -64,7 +68,8 @@ extern void testingTSkipNow(testingT *t);
|
|||
extern void testingTDefer(testingT *t, void (*f)(testingT *t, void *data), void *data);
|
||||
|
||||
extern void testingprivRegisterTest(const char *, void (*)(testingT *));
|
||||
extern void testingprivRegisterManualTest(const char *, void (*)(testingT *));
|
||||
extern void testingprivRegisterTestBefore(const char *, void (*)(testingT *));
|
||||
extern void testingprivRegisterTestAfter(const char *, void (*)(testingT *));
|
||||
// see https://stackoverflow.com/questions/32399191/va-args-expansion-using-msvc
|
||||
#define testingprivExpand(x) x
|
||||
#define testingprivTLogfThen(then, t, ...) ((testingprivTLogfFull(t, __FILE__, __LINE__, __VA_ARGS__)), (then(t)))
|
||||
|
|
Loading…
Reference in New Issue