Made the test for an invalid control type slightly more robust by not using either 0 or 5 for the fake object (but rather some other value that isn't the constant and that's also conveniently ASCII) and deduplicating the redundant tests.

This commit is contained in:
Pietro Gagliardi 2020-05-10 22:00:49 -04:00
parent c52656f2c2
commit e71c717b31
2 changed files with 2 additions and 13 deletions

View File

@ -222,7 +222,8 @@ void *uiControlImplData(uiControl *c)
}
static uiControl testHookControlWithInvalidControlMarker = {
.controlID = 0,
// use something other than 0 here to make it look like accidental real data
.controlID = UINT32_C(0x5A5A5A5A),
};
uiControl *uiprivTestHookControlWithInvalidControlMarker(void)

View File

@ -176,19 +176,7 @@ Test(CheckingNullControlIsProgrammerError)
endCheckProgrammerError(ctx);
}
// TODO should this test be the same as the following one instead?
Test(CheckingNonControlIsProgrammerError)
{
// 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";
void *ctx;
ctx = beginCheckProgrammerError("uiCheckControlType(): object passed in not a uiControl");
uiCheckControlType(buf, uiControlType());
endCheckProgrammerError(ctx);
}
Test(CheckingControlWithoutControlMarkerIsProgrammerError)
{
void *ctx;