And reintegrated the macOS tests. Now for the other platforms.

This commit is contained in:
Pietro Gagliardi 2020-05-11 22:19:07 -04:00
parent 76eef19a2b
commit 22bcf088e9
4 changed files with 29 additions and 34 deletions

View File

@ -12,6 +12,14 @@ static void vtableNopFree(uiControl *c, void *implData)
// do nothing
}
void testControlLoadNopVtable(uiControlVtable *vtable)
{
memset(vtable, 0, sizeof (uiControlVtable));
vtable->Size = sizeof (uiControlVtable);
vtable->Init = vtableNopInit;
vtable->Free = vtableNopFree;
}
// TODO we'll have to eventually find out for real if memset(0) is sufficient to set pointers to NULL or not; C99 doesn't seem to say
Test(ControlImplDataIsClearedOnNewControl)
{
@ -21,10 +29,7 @@ Test(ControlImplDataIsClearedOnNewControl)
uiControl *c;
char *implData;
memset(&vt, 0, sizeof (uiControlVtable));
vt.Size = sizeof (uiControlVtable);
vt.Init = vtableNopInit;
vt.Free = vtableNopFree;
testControlLoadNopVtable(&vt);
type = uiRegisterControlType("TestControl", &vt, testOSVtable(), sizeof (memory));
c = uiNewControl(type, NULL);
implData = (char *) uiControlImplData(c);
@ -40,10 +45,7 @@ Test(ZeroSizeImplDataIsNULL)
uint32_t type;
uiControl *c;
memset(&vt, 0, sizeof (uiControlVtable));
vt.Size = sizeof (uiControlVtable);
vt.Init = vtableNopInit;
vt.Free = vtableNopFree;
testControlLoadNopVtable(&vt);
type = uiRegisterControlType("TestControl", &vt, testOSVtable(), 0);
c = uiNewControl(type, NULL);
if (uiControlImplData(c) != NULL)
@ -181,7 +183,7 @@ Test(WrongControlVtableSizeIsProgrammerError)
endCheckProgrammerError(ctx);
}
Test(ControlVtableWithMIssingInitMethodIsProgrammerError)
Test(ControlVtableWithMissingInitMethodIsProgrammerError)
{
uiControlVtable vt;
void *ctx;
@ -193,7 +195,7 @@ Test(ControlVtableWithMIssingInitMethodIsProgrammerError)
endCheckProgrammerError(ctx);
}
Test(ControlVtableWithMIssingFreeMethodIsProgrammerError)
Test(ControlVtableWithMissingFreeMethodIsProgrammerError)
{
uiControlVtable vt;
void *ctx;

View File

@ -1,11 +1,25 @@
// 10 june 2019
#import "test_darwin.h"
static const uiControlOSVtable vtable = {
static const uiControlOSVtable osVtable = {
.Size = sizeof (uiControlOSVtable),
};
const uiControlOSVtable *testOSVtable(void)
{
return &vtable;
return &osVtable;
}
Test(WrongControlOSVtableSizeIsProgrammerError)
{
uiControlVtable vtable;
uiControlOSVtable osvt;
void *ctx;
testControlLoadNopVtable(&vtable);
ctx = beginCheckProgrammerError("uiRegisterControlType(): wrong size 1 for uiControlOSVtable");
memset(&osvt, 0, sizeof (uiControlOSVtable));
osvt.Size = 1;
uiRegisterControlType("name", &vtable, &osvt, 0);
endCheckProgrammerError(ctx);
}

View File

@ -83,6 +83,7 @@ extern void endCheckProgrammerErrorFull(const char *file, long line, void *conte
#define endCheckProgrammerError(context) endCheckProgrammerErrorFull(__FILE__, __LINE__, context)
// controls.c
extern void testControlLoadNopVtable(uiControlVtable *vtable);
extern const uiControlOSVtable *testOSVtable(void);
#ifdef __cplusplus

View File

@ -1,22 +0,0 @@
// 16 june 2019
#import "test_darwin.h"
// TODO move this back to C++ once https://github.com/mesonbuild/meson/issues/5495 is resolved
static void doRCTWrongSizeTest(void)
{
uiControlOSVtable vtable;
memset(&vtable, 0, sizeof (uiControlOSVtable));
vtable.Size = 1;
uiRegisterControlType("name", testVtable(), &vtable, 0);
}
const struct checkErrorCase controlOSVtableCases[] = {
{
"uiRegisterControlType() with OS vtable with wrong size",
doRCTWrongSizeTest,
"uiRegisterControlType(): wrong size 1 for uiControlOSVtable",
},
{ NULL, NULL, NULL },
};