diff --git a/test/controls_unix.c b/test/controls_unix.c new file mode 100644 index 00000000..29b48a7d --- /dev/null +++ b/test/controls_unix.c @@ -0,0 +1,25 @@ +// 10 june 2019 +#include "test_unix.h" + +static const uiControlOSVtable osVtable = { + .Size = sizeof (uiControlOSVtable), +}; + +const uiControlOSVtable *testOSVtable(void) +{ + 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); +} diff --git a/test/meson.build b/test/meson.build index 2cee2e93..5a2dece3 100644 --- a/test/meson.build +++ b/test/meson.build @@ -17,6 +17,10 @@ elif libui_OS == 'darwin' libui_test_sources += files([ 'controls_darwin.m', ]) +else + libui_test_sources += files([ + 'controls_unix.c', + ]) endif libui_test_sources_without_cases = [ diff --git a/zNEW_test/test_unix.h b/test/test_unix.h similarity index 100% rename from zNEW_test/test_unix.h rename to test/test_unix.h diff --git a/zNEW_test/controls_unix.c b/zNEW_test/controls_unix.c deleted file mode 100644 index 103851a9..00000000 --- a/zNEW_test/controls_unix.c +++ /dev/null @@ -1,11 +0,0 @@ -// 10 june 2019 -#include "test_unix.h" - -static const uiControlOSVtable vtable = { - .Size = sizeof (uiControlOSVtable), -}; - -const uiControlOSVtable *testOSVtable(void) -{ - return &vtable; -} diff --git a/zNEW_test/controls_unix_errors.cpp b/zNEW_test/controls_unix_errors.cpp deleted file mode 100644 index 55cda580..00000000 --- a/zNEW_test/controls_unix_errors.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// 16 june 2019 -#include "test_unix.h" - -const struct checkErrorCase controlOSVtableCases[] = { - { - "uiRegisterControlType() with OS vtable with wrong size", - [](void) { - uiControlOSVtable vtable; - - memset(&vtable, 0, sizeof (uiControlOSVtable)); - vtable.Size = 1; - uiRegisterControlType("name", testVtable(), &vtable, 0); - }, - "uiRegisterControlType(): wrong size 1 for uiControlOSVtable", - }, - { NULL, NULL, NULL }, -};