Added test hook for checking a malformed uiControl whose type field is invalid.

This commit is contained in:
Pietro Gagliardi 2019-06-16 17:26:03 -04:00
parent f90150a579
commit c28adcbd01
3 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,6 @@
// 8 june 2019
#include "uipriv.h"
#include "testhooks.h"
struct controlType {
uint32_t id;
@ -202,3 +203,13 @@ void *uiControlImplData(uiControl *c)
}
return c->implData;
}
static uiControl testHookControlWithInvalidType = {
.controlID = controlTypeID,
.typeID = 5,
};
uiControl *uiprivTestHookControlWithInvalidType(void)
{
return &testHookControlWithInvalidType;
}

View File

@ -8,6 +8,9 @@ extern "C" {
typedef void (*uiprivTestHookReportProgrammerErrorFunc)(const char *msg, void *data);
uiprivExtern void uiprivTestHookReportProgrammerError(uiprivTestHookReportProgrammerErrorFunc f, void *data);
// controls.c
uiprivExtern uiControl *uiprivTestHookControlWithInvalidType(void);
#ifdef __cplusplus
}
#endif

View File

@ -73,9 +73,16 @@ static const struct checkErrorCase casesAfterOSVtable[] = {
{
"uiCheckControlType() with a control with an unknown type",
[](void) {
// TODO
uiCheckControlType(uiprivTestHookControlWithInvalidType(), testControlType);
},
"TODO",
"uiCheckControlType(): unknown uiControl type 5 found in uiControl (this is likely not a real uiControl or some data is corrupt)",
},
{
"uiCheckControlType() with a control with an unknown type, even with uiControlType()",
[](void) {
uiCheckControlType(uiprivTestHookControlWithInvalidType(), uiControlType());
},
"uiCheckControlType(): unknown uiControl type 5 found in uiControl (this is likely not a real uiControl or some data is corrupt)",
},
{
"uiCheckControlType() asking for an unknown control type",