Fixed the test suite.

This commit is contained in:
Pietro Gagliardi 2019-04-10 20:11:44 -04:00
parent 4f381d04a1
commit 1b046e763b
6 changed files with 22 additions and 19 deletions

0
dummy.c Normal file
View File

View File

@ -140,15 +140,16 @@ libui_sources = []
libui_deps = []
libui_soversion = ''
libui_rpath = ''
subdir('common')
#subdir('common')
libui_sources+=['dummy.c']
if libui_OS == 'windows'
subdir('windows')
# subdir('windows')
install_headers('ui_windows.h')
elif libui_OS == 'darwin'
subdir('darwin')
# subdir('darwin')
install_headers('ui_darwin.h')
else
subdir('unix')
# subdir('unix')
install_headers('ui_unix.h')
endif
libui_libui = library('ui', libui_sources,
@ -173,4 +174,4 @@ if libui_mode == 'static'
libui_binary_deps = libui_deps
endif
subdir('test')
subdir('examples')
#subdir('examples')

View File

@ -2,11 +2,11 @@
#include "../ui.h"
#include "testing.h"
Test(Init)
testingTest(Init)
{
}
Test(Uninit)
testingTest(Uninit)
{
}
@ -17,7 +17,7 @@ static void queued(void *data)
*flag = 1;
}
static void timer(void *n)
static void timer(void *data)
{
int *n = (int *) data;
@ -25,12 +25,12 @@ static void timer(void *n)
*n++;
}
Test(QueueMain)
testingTest(QueueMain)
{
}
// TODO Test(QueueMain_DifferentThread)
// TODO testingTest(QueueMain_DifferentThread)
Test(Timer)
testingTest(Timer)
{
}

View File

@ -2,6 +2,7 @@
libui_test_sources = [
'initmain.c',
'main.c',
'testing.c',
]

View File

@ -27,7 +27,7 @@ struct testingT {
static testingT *tests = NULL;
static testingT *testsTail = NULL;
static void testingprivNewTest(const char *name, void (*f)(testingT *), testingT *prev)
static testingT *newTest(const char *name, void (*f)(testingT *), testingT *prev)
{
testingT *t;
@ -39,7 +39,9 @@ static void testingprivNewTest(const char *name, void (*f)(testingT *), testingT
t->returned = 0;
t->defers = NULL;
t->defersRun = 0;
t->next = testsTail;
t->next = NULL;
if (prev != NULL)
prev->next = t;
return t;
}
@ -47,7 +49,7 @@ void testingprivRegisterTest(const char *name, void (*f)(testingT *))
{
testingT *t;
t = testingprivNewTest(name, f, testsTail);
t = newTest(name, f, testsTail);
testsTail = t;
if (tests == NULL)
tests = t;
@ -87,7 +89,6 @@ static void runTestSet(testingT *t, int *anyFailed)
int testingMain(void)
{
testingT *t;
int anyFailed;
// TODO see if this should run if all tests are skipped
@ -119,7 +120,7 @@ void testingprivTLogfFull(testingT *t, const char *file, long line, const char *
void testingprivTLogvfFull(testingT *t, const char *file, long line, const char *format, va_list ap)
{
// TODO extract filename from file
printf("\t%s:%d: ", file, line);
printf("\t%s:%ld: ", file, line);
// TODO split into lines separated by \n\t\t and trimming trailing empty lines
vprintf(format, ap);
printf("\n");
@ -153,7 +154,7 @@ void testingprivTSkipNow(testingT *t)
returnNow(t);
}
void testingTDefer(testingT *t, void (*f)(void *data), void *data)
void testingTDefer(testingT *t, void (*f)(testingT *t, void *data), void *data)
{
struct defer *d;

View File

@ -6,11 +6,11 @@
#include <stdarg.h>
#define testingprivFullName(basename) testingprivImpl ## basename
#define testingprivImplName(basename) testingprivImpl ## basename
#define testingprivScaffoldName(basename) testingprivScaffold ## basename
#define testingprivMkScaffold(basename, argtype, argname) \
static inline void testingprivScaffoldName(basename)(argtype *argname) { testingprivFullName(basename)(argname); }
static inline void testingprivScaffoldName(basename)(argtype *argname) { testingprivImplName(basename)(argname); }
// references:
// - https://gitlab.gnome.org/GNOME/glib/blob/master/glib/gconstructor.h