More filling in of the uiControl errors tests.
This commit is contained in:
parent
0d61f674c5
commit
f90150a579
|
@ -7,9 +7,12 @@ struct testImplData {
|
|||
bool testMethodCalled;
|
||||
};
|
||||
|
||||
static int failInit = 5;
|
||||
void *testControlFailInit = &failInit;
|
||||
|
||||
static bool testVtableInit(uiControl *c, void *implData, void *initData)
|
||||
{
|
||||
return true;
|
||||
return initData != testControlFailInit;
|
||||
}
|
||||
|
||||
static void testVtableFree(uiControl *c, void *implData)
|
||||
|
@ -35,3 +38,4 @@ size_t testImplDataSize(void)
|
|||
|
||||
// TODO explicitly make/document 0 as always invalid
|
||||
uint32_t testControlType = 0;
|
||||
uint32_t testControlType2 = 0;
|
||||
|
|
|
@ -80,16 +80,24 @@ static const struct checkErrorCase casesAfterOSVtable[] = {
|
|||
{
|
||||
"uiCheckControlType() asking for an unknown control type",
|
||||
[](void) {
|
||||
// TODO
|
||||
uiControl *c;
|
||||
|
||||
c = uiNewControl(testControlType, NULL);
|
||||
uiCheckControlType(c, 5);
|
||||
uiControlFree(c);
|
||||
},
|
||||
"TODO",
|
||||
"uiCheckControlType(): unknown uiControl type 5 requested",
|
||||
},
|
||||
{
|
||||
"uiCheckControlType() with a type mismatch",
|
||||
[](void) {
|
||||
// TODO
|
||||
uiControl *c;
|
||||
|
||||
c = uiNewControl(testControlType, NULL);
|
||||
uiCheckControlType(c, testControlType2);
|
||||
uiControlFree(c);
|
||||
},
|
||||
"TODO",
|
||||
"uiCheckControlType(): wrong uiControl type passed: got TestControl, want TestControl2",
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -106,9 +114,28 @@ static const struct checkErrorCase casesAfterOSVtable[] = {
|
|||
},
|
||||
"uiNewControl(): unknown uiControl type 5 requested",
|
||||
},
|
||||
// TODO have Init() fail
|
||||
{
|
||||
"uiNewControl() with Init() failing",
|
||||
[](void) {
|
||||
uiNewControl(testControlType, testControlFailInit);
|
||||
},
|
||||
"uiNewControl(): invalid init data for TestControl",
|
||||
},
|
||||
|
||||
// TODO uiControlFree()
|
||||
{
|
||||
"uiControlFree() with a NULL uiControl",
|
||||
[](void) {
|
||||
uiControlFree(NULL);
|
||||
},
|
||||
"uiControlFree(): invalid null pointer for uiControl",
|
||||
},
|
||||
{
|
||||
"uiControlFree() with a uiControl that still has a parent",
|
||||
[](void) {
|
||||
// TODO
|
||||
},
|
||||
"TODO",
|
||||
},
|
||||
|
||||
{
|
||||
"uiControlImplData() with a NULL uiControl",
|
||||
|
|
|
@ -50,6 +50,8 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
testControlType = uiRegisterControlType("TestControl", testVtable(), testOSVtable(), testImplDataSize());
|
||||
testControlType2 = uiRegisterControlType("TestControl2", testVtable(), testOSVtable(), testImplDataSize());
|
||||
|
||||
runSetORingResults(NULL, &opts, &anyRun, &anyFailed);
|
||||
|
||||
if (!anyRun)
|
||||
|
|
|
@ -50,10 +50,12 @@ extern void checkProgrammerErrorsFull(testingT *t, const char *file, long line,
|
|||
#define checkProgrammerErrorsInThread(t, cases) checkProgrammerErrorsFull(t, __FILE__, __LINE__, cases, true)
|
||||
|
||||
// controls.c
|
||||
extern void *testControlFailInit;
|
||||
extern const uiControlVtable *testVtable(void);
|
||||
extern const uiControlOSVtable *testOSVtable(void);
|
||||
extern size_t testImplDataSize(void);
|
||||
extern uint32_t testControlType;
|
||||
extern uint32_t testControlType2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue