Finished the boilerplate for the uiOpenTypeFeatures test.

This commit is contained in:
Pietro Gagliardi 2018-02-28 01:21:10 -05:00
parent 70815d8d7b
commit 5ab1266b5d
1 changed files with 40 additions and 12 deletions

View File

@ -1,10 +1,26 @@
xx 27 february 2018 // 27 february 2018
#ifndef TODO_TEST #ifndef TODO_TEST
#error TODO this is where libui itself goes #error TODO this is where libui itself goes
#endif #endif
#include <stdarg.h> #include <stdarg.h>
#undef testingprivBadLanguageVersion
#ifdef __cplusplus
// TODO https://stackoverflow.com/questions/2324658/how-to-determine-the-version-of-the-c-standard-used-by-the-compiler implies this won't do with C++0x-era compilers, and https://wiki.apache.org/stdcxx/C++0xCompilerSupport doesn't talk about va_copy() so a simple version check for the C99 preprocessor may be wrong...
// TODO what if __cplusplus is blank (maybe only in that case, since IIRC C++98 requires __cplusplus to have a value)?
#if __cplusplus < 201103L
#define testingprivBadLanguageVersion
#endif
#elif !defined(__STDC_VERSION__)
#define testingprivBadLanguageVersion
#elif __STDC_VERSION__ < 199901L
#define testingprivBadLanguageVersion
#endif
#ifdef testingprivBadLanguageVersion
#error sorry, TODO requires either C99 or TODO; cannot continue
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -21,13 +37,13 @@ extern "C" {
extern int testingMain(void); extern int testingMain(void);
typedef struct testingT testingT; typedef struct testingT testingT;
#define testingTErrorf(t, ...) testingprivTLogFull(t, __FILE__, __LINE__, __VA_ARGS__) #define testingTErrorf(t, ...) testingprivTErrorfFull(t, __FILE__, __LINE__, __VA_ARGS__)
#define testingTErrorvf(t, format, ap) testingprivTLogFullv(t, __FILE__, __LINE__, format, ap) #define testingTErrorvf(t, format, ap) testingprivTErrorvfFull(t, __FILE__, __LINE__, format, ap)
extern void testingprivRegisterTest(const char *, void (*)(testi // TODO should __LINE__ arguments use intmax_t or uintmax_t instead of int?
ngT *)); extern void testingprivRegisterTest(const char *, void (*)(testingT *));
extern void testingprivTLogFull(testingT *, const char *, int, const char *, ...); extern void testingprivTErrorfFull(testingT *, const char *, int, const char *, ...);
extern void testingprivTLogFullv(testingT *, const char *, int, const char *, va_list); extern void testingprivTErrorvfFull(testingT *, const char *, int, const char *, va_list);
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -35,6 +51,7 @@ extern void testingprivTLogFullv(testingT *, const char *, int, const char *, va
testingTest(Name) testingTest(Name)
{ {
printf("in the test!\n");
} }
int main(void) int main(void)
@ -60,7 +77,7 @@ void testingprivRegisterTest(const char *name, void (*f)(testingT *))
{ {
testingT *t; testingT *t;
t = testingprivNew(testingT) t = testingprivNew(testingT);
t->name = name; t->name = name;
t->f = f; t->f = f;
t->failed = 0; t->failed = 0;
@ -76,7 +93,7 @@ int testingMain(void)
if (tests == NULL) { if (tests == NULL) {
fprintf(stderr, "warning: no tests to run\n"); fprintf(stderr, "warning: no tests to run\n");
xx imitate Go here (TODO confirm this) // imitate Go here (TODO confirm this)
return 0; return 0;
} }
@ -100,15 +117,26 @@ int testingMain(void)
return 0; return 0;
} }
extern void testingprivTLogFull(testingT *t, const char *file, int line, const char *format, ...) static void testingprivTDoLog(testingT *t, const char *file, int line, const char *format, va_list ap)
{
// TODO extract filename from file
printf("\t%s:%d: ", file, line);
// TODO split into lines separated by \n\t\t and trimming trailing empty lines
vprintf(format, ap);
printf("\n");
}
void testingprivTErrorfFull(testingT *t, const char *file, int line, const char *format, ...)
{ {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
testingprivTLogFullv(t, file, line, format, ap); testingprivTErrorvfFull(t, file, line, format, ap);
va_end(ap); va_end(ap);
} }
void testingprivTLogFullv(testingT *t, const char *file, int line, const char *format, va_list ap) void testingprivTErrorvfFull(testingT *t, const char *file, int line, const char *format, va_list ap)
{ {
testingprivTDoLog(t, file, line, format, ap);
t->failed = 1;
} }