And strengthened the uiControlType() test a bit.
This commit is contained in:
parent
c28adcbd01
commit
fda6c4a743
|
@ -204,6 +204,15 @@ void *uiControlImplData(uiControl *c)
|
||||||
return c->implData;
|
return c->implData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uiControl testHookControlWithInvalidControlMarker = {
|
||||||
|
.controlID = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
uiControl *uiprivTestHookControlWithInvalidControlMarker(void)
|
||||||
|
{
|
||||||
|
return &testHookControlWithInvalidControlMarker;
|
||||||
|
}
|
||||||
|
|
||||||
static uiControl testHookControlWithInvalidType = {
|
static uiControl testHookControlWithInvalidType = {
|
||||||
.controlID = controlTypeID,
|
.controlID = controlTypeID,
|
||||||
.typeID = 5,
|
.typeID = 5,
|
||||||
|
|
|
@ -9,6 +9,7 @@ typedef void (*uiprivTestHookReportProgrammerErrorFunc)(const char *msg, void *d
|
||||||
uiprivExtern void uiprivTestHookReportProgrammerError(uiprivTestHookReportProgrammerErrorFunc f, void *data);
|
uiprivExtern void uiprivTestHookReportProgrammerError(uiprivTestHookReportProgrammerErrorFunc f, void *data);
|
||||||
|
|
||||||
// controls.c
|
// controls.c
|
||||||
|
uiprivExtern uiControl *uiprivTestHookControlWithInvalidControlMarker(void);
|
||||||
uiprivExtern uiControl *uiprivTestHookControlWithInvalidType(void);
|
uiprivExtern uiControl *uiprivTestHookControlWithInvalidType(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -64,12 +64,20 @@ static const struct checkErrorCase casesAfterOSVtable[] = {
|
||||||
{
|
{
|
||||||
"uiCheckControlType() with non-control",
|
"uiCheckControlType() with non-control",
|
||||||
[](void) {
|
[](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(buf, uiControlType());
|
||||||
},
|
},
|
||||||
"uiCheckControlType(): object passed in not a uiControl",
|
"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",
|
"uiCheckControlType() with a control with an unknown type",
|
||||||
[](void) {
|
[](void) {
|
||||||
|
|
Loading…
Reference in New Issue