And strengthened the uiControlType() test a bit.

This commit is contained in:
Pietro Gagliardi 2019-06-16 17:32:47 -04:00
parent c28adcbd01
commit fda6c4a743
3 changed files with 19 additions and 1 deletions

View File

@ -204,6 +204,15 @@ void *uiControlImplData(uiControl *c)
return c->implData;
}
static uiControl testHookControlWithInvalidControlMarker = {
.controlID = 5,
};
uiControl *uiprivTestHookControlWithInvalidControlMarker(void)
{
return &testHookControlWithInvalidControlMarker;
}
static uiControl testHookControlWithInvalidType = {
.controlID = controlTypeID,
.typeID = 5,

View File

@ -9,6 +9,7 @@ typedef void (*uiprivTestHookReportProgrammerErrorFunc)(const char *msg, void *d
uiprivExtern void uiprivTestHookReportProgrammerError(uiprivTestHookReportProgrammerErrorFunc f, void *data);
// controls.c
uiprivExtern uiControl *uiprivTestHookControlWithInvalidControlMarker(void);
uiprivExtern uiControl *uiprivTestHookControlWithInvalidType(void);
#ifdef __cplusplus

View File

@ -64,12 +64,20 @@ static const struct checkErrorCase casesAfterOSVtable[] = {
{
"uiCheckControlType() with non-control",
[](void) {
static char buf[] = "this is not a uiControl";
// TODO make sure this is fine; if not, just use the following check instead
static char buf[] = "this is not a uiControl but is big enough to at the very least not cause a problem with UB hopefully";
uiCheckControlType(buf, uiControlType());
},
"uiCheckControlType(): object passed in not a uiControl",
},
{
"uiCheckControlType() with uiControl without uiControlType() marker",
[](void) {
uiCheckControlType(uiprivTestHookControlWithInvalidControlMarker(), uiControlType());
},
"uiCheckControlType(): object passed in not a uiControl",
},
{
"uiCheckControlType() with a control with an unknown type",
[](void) {