diff --git a/test/testing.c b/test/testing.c index 3ff2688d..d1ee094f 100644 --- a/test/testing.c +++ b/test/testing.c @@ -31,10 +31,11 @@ static testingT *testsBeforeTail = NULL; static testingT *testsAfter = NULL; static testingT *testsAfterTail = NULL; -static testingT *newTest(const char *name, void (*f)(testingT *), testingT *prev) +static testingT *newTest(const char *name, void (*f)(testingT *), const char *file, long line, testingT *prev) { testingT *t; +printf("%s %s %ld\n", name, file, line); t = testingprivNew(testingT); t->name = name; t->f = f; @@ -49,31 +50,31 @@ static testingT *newTest(const char *name, void (*f)(testingT *), testingT *prev return t; } -void testingprivRegisterTest(const char *name, void (*f)(testingT *)) +void testingprivRegisterTest(const char *name, void (*f)(testingT *), const char *file, long line) { testingT *t; - t = newTest(name, f, testsTail); + t = newTest(name, f, file, line, testsTail); testsTail = t; if (tests == NULL) tests = t; } -void testingprivRegisterTestBefore(const char *name, void (*f)(testingT *)) +void testingprivRegisterTestBefore(const char *name, void (*f)(testingT *), const char *file, long line) { testingT *t; - t = newTest(name, f, testsBeforeTail); + t = newTest(name, f, file, line, testsBeforeTail); testsBeforeTail = t; if (testsBefore == NULL) testsBefore = t; } -void testingprivRegisterTestAfter(const char *name, void (*f)(testingT *)) +void testingprivRegisterTestAfter(const char *name, void (*f)(testingT *), const char *file, long line) { testingT *t; - t = newTest(name, f, testsAfterTail); + t = newTest(name, f, file, line, testsAfterTail); testsAfterTail = t; if (testsAfter == NULL) testsAfter = t; diff --git a/test/testing.h b/test/testing.h index 7bcdb8c9..2f969be1 100644 --- a/test/testing.h +++ b/test/testing.h @@ -20,10 +20,10 @@ #define testingprivCtorPtrName(basename) testingprivCtorPtr ## basename #if defined(__GNUC__) #define testingprivMkCtor(basename, regfunc) \ - __attribute__((constructor)) static void testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename)); } + __attribute__((constructor)) static void testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename), __FILE__, __LINE__); } #elif defined(_MSC_VER) #define testingprivMkCtor(basename, reg) \ - static int testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename)); return 0; } \ + static int testingprivCtorName(basename)(void) { regfunc(#basename, testingprivScaffoldName(basename), __FILE__, __LINE__); return 0; } \ __pragma(section(".CRT$XCU",read)) \ __declspec(allocate(".CRT$XCU")) static int (*testingprivCtorPtrName(basename))(void) = testingprivCtorName(basename); #else @@ -67,9 +67,9 @@ extern void testingTFailNow(testingT *t); 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 testingprivRegisterTestBefore(const char *, void (*)(testingT *)); -extern void testingprivRegisterTestAfter(const char *, void (*)(testingT *)); +extern void testingprivRegisterTest(const char *, void (*)(testingT *), const char *, long); +extern void testingprivRegisterTestBefore(const char *, void (*)(testingT *), const char *, long); +extern void testingprivRegisterTestAfter(const char *, void (*)(testingT *), const char *, long); // 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)))