2020-01-20 16:22:37 -06:00
|
|
|
// 27 february 2018
|
2020-01-20 19:52:46 -06:00
|
|
|
#include <inttypes.h>
|
2020-01-20 16:22:37 -06:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "../ui.h"
|
2020-01-20 19:52:46 -06:00
|
|
|
#ifdef libuiOSHeader
|
|
|
|
#include libuiOSHeader
|
2020-01-20 16:22:37 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define testingprivImplName(basename) testingprivImpl ## basename
|
2020-01-20 19:49:33 -06:00
|
|
|
#define testingprivScaffoldName(basename) testingprivScaffold ## basename
|
|
|
|
|
2020-01-20 16:22:37 -06:00
|
|
|
#define Test(Name) \
|
2020-02-16 17:42:02 -06:00
|
|
|
static void testingprivImplName(Test ## Name)(void); \
|
|
|
|
void testingprivScaffoldName(Test ## Name)(void) \
|
2020-01-21 00:16:47 -06:00
|
|
|
{ \
|
|
|
|
uiInitError err; \
|
|
|
|
memset(&err, 0, sizeof (uiInitError)); \
|
|
|
|
err.Size = sizeof (uiInitError); \
|
|
|
|
if (!uiInit(NULL, &err)) { \
|
|
|
|
fprintf(stderr, "error initializing libui for Test" #Name ": %s\n", err.Message); \
|
2020-01-23 09:52:41 -06:00
|
|
|
TestFailNow(); \
|
2020-01-21 00:16:47 -06:00
|
|
|
} \
|
2020-01-23 09:52:41 -06:00
|
|
|
testingprivImplName(Test ## Name)(); \
|
2020-01-21 00:16:47 -06:00
|
|
|
} \
|
2020-02-16 17:42:02 -06:00
|
|
|
static void testingprivImplName(Test ## Name)(void)
|
2020-01-21 00:16:47 -06:00
|
|
|
|
|
|
|
#define TestNoInit(Name) \
|
2020-02-16 17:42:02 -06:00
|
|
|
static void testingprivImplName(Test ## Name)(void); \
|
|
|
|
void testingprivScaffoldName(Test ## Name)(void) \
|
2020-01-21 00:16:47 -06:00
|
|
|
{ \
|
2020-01-23 09:52:41 -06:00
|
|
|
testingprivImplName(Test ## Name)(); \
|
2020-01-21 00:16:47 -06:00
|
|
|
} \
|
2020-02-16 17:42:02 -06:00
|
|
|
static void testingprivImplName(Test ## Name)(void)
|
2020-01-20 16:22:37 -06:00
|
|
|
|
2020-01-23 09:52:41 -06:00
|
|
|
extern void TestFail(void);
|
|
|
|
extern void TestFailNow(void);
|
|
|
|
extern void TestSkipNow(void);
|
2020-01-20 19:49:33 -06:00
|
|
|
|
|
|
|
#define TestLogf(...) \
|
2020-01-23 09:52:41 -06:00
|
|
|
(testingprivLogfFullThen(stdout, NULL, __FILE__, __LINE__, __VA_ARGS__))
|
2020-01-23 20:44:45 -06:00
|
|
|
#define TestLogfFull(f, n, ...) \
|
|
|
|
(testingprivLogfFullThen(stdout, NULL, f, n, __VA_ARGS__))
|
2020-01-20 19:49:33 -06:00
|
|
|
#define TestErrorf(...) \
|
2020-01-23 09:52:41 -06:00
|
|
|
(testingprivLogfFullThen(stderr, TestFail, __FILE__, __LINE__, __VA_ARGS__))
|
2020-01-23 20:44:45 -06:00
|
|
|
#define TestErrorfFull(f, n, ...) \
|
|
|
|
(testingprivLogfFullThen(stderr, TestFail, f, n, __VA_ARGS__))
|
2020-01-20 19:49:33 -06:00
|
|
|
#define TestFatalf(...) \
|
2020-01-23 09:52:41 -06:00
|
|
|
(testingprivLogfFullThen(stderr, TestFailNow, __FILE__, __LINE__, __VA_ARGS__))
|
2020-01-23 20:44:45 -06:00
|
|
|
#define TestFatalfFull(f, n, ...) \
|
|
|
|
(testingprivLogfFullThen(stderr, TestFailNow, f, n, __VA_ARGS__))
|
2020-01-20 19:49:33 -06:00
|
|
|
// TODO remember if this needs to go to stdout or to stderr
|
|
|
|
#define TestSkipf(...) \
|
2020-01-23 09:52:41 -06:00
|
|
|
(testingprivLogfFullThen(stderr, TestSkipNow, __FILE__, __LINE__, __VA_ARGS__))
|
2020-01-23 20:44:45 -06:00
|
|
|
// TODO TestSkipfFull (after resolving above TODO)
|
2020-01-20 16:22:37 -06:00
|
|
|
|
2020-01-20 19:49:33 -06:00
|
|
|
#include "../sharedbits/printfwarn_header.h"
|
|
|
|
sharedbitsPrintfFunc(
|
2020-01-23 09:52:41 -06:00
|
|
|
extern void testingprivLogfFullThen(FILE *f, void (*then)(void), const char *filename, long line, const char *fmt, ...),
|
|
|
|
5, 6);
|
2020-01-20 19:49:33 -06:00
|
|
|
#undef sharedbitsPrintfFunc
|
2020-01-20 16:22:37 -06:00
|
|
|
|
2020-02-16 17:31:53 -06:00
|
|
|
#include "testlist.h"
|
|
|
|
|
2020-01-20 19:52:46 -06:00
|
|
|
// end of test framework definitions
|
|
|
|
|
|
|
|
#define diff(fmt) "\ngot " fmt "\nwant " fmt
|
|
|
|
|
2020-01-26 19:02:03 -06:00
|
|
|
// errors.c
|
|
|
|
struct checkErrorCase {
|
|
|
|
const char *name;
|
|
|
|
void (*f)(void);
|
|
|
|
const char *msgWant;
|
|
|
|
};
|
|
|
|
extern void checkProgrammerErrorsFull(const char *file, long line, const struct checkErrorCase *cases, bool inThread);
|
|
|
|
#define checkProgrammerErrors(cases) checkProgrammerErrorsFull(__FILE__, __LINE__, cases, false)
|
|
|
|
#define checkProgrammerErrorsInThread(cases) checkProgrammerErrorsFull(__FILE__, __LINE__, cases, true)
|
|
|
|
|
2020-01-20 16:22:37 -06:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|