Explicitly specified 0 as the invalid control type and stopped using 5 as an invalid control type.
This commit is contained in:
parent
3689d3c96a
commit
c52656f2c2
|
@ -222,7 +222,7 @@ void *uiControlImplData(uiControl *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
static uiControl testHookControlWithInvalidControlMarker = {
|
static uiControl testHookControlWithInvalidControlMarker = {
|
||||||
.controlID = 5,
|
.controlID = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
uiControl *uiprivTestHookControlWithInvalidControlMarker(void)
|
uiControl *uiprivTestHookControlWithInvalidControlMarker(void)
|
||||||
|
@ -232,7 +232,7 @@ uiControl *uiprivTestHookControlWithInvalidControlMarker(void)
|
||||||
|
|
||||||
static uiControl testHookControlWithInvalidType = {
|
static uiControl testHookControlWithInvalidType = {
|
||||||
.controlID = controlTypeID,
|
.controlID = controlTypeID,
|
||||||
.typeID = 5,
|
.typeID = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
uiControl *uiprivTestHookControlWithInvalidType(void)
|
uiControl *uiprivTestHookControlWithInvalidType(void)
|
||||||
|
|
|
@ -18,7 +18,7 @@ uint32_t uiControlType(void);
|
||||||
|
|
||||||
`uiControl` is an opaque type that describes a control.
|
`uiControl` is an opaque type that describes a control.
|
||||||
|
|
||||||
`uiControlType()` is the type identifier of a `uiControl` as passed to `uiCheckControlType()`. You rarely need to call this directly; the `uiControl()` conversion macro does this for you.
|
`uiControlType()` is the type identifier of a `uiControl` as passed to `uiCheckControlType()`. You rarely need to call this directly; the `uiControl()` conversion macro does this for you. A control type identifier of 0 is always invalid; this can be used to initialize the variables that hold the returned identifiers from `uiRegisterControlType()`.
|
||||||
|
|
||||||
### `uiControlVtable`
|
### `uiControlVtable`
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "../common/testhooks.h"
|
#include "../common/testhooks.h"
|
||||||
|
|
||||||
// TODO replace hardcoded control types of 5 with a constant from the test hook system
|
|
||||||
// TODO also test 0 here too
|
|
||||||
|
|
||||||
struct counts {
|
struct counts {
|
||||||
unsigned int countInit;
|
unsigned int countInit;
|
||||||
unsigned int countFree;
|
unsigned int countFree;
|
||||||
|
@ -55,7 +52,6 @@ static const uiControlVtable vtable = {
|
||||||
|
|
||||||
static uint32_t testControlType(void)
|
static uint32_t testControlType(void)
|
||||||
{
|
{
|
||||||
// TODO explicitly make/document 0 as always invalid
|
|
||||||
static uint32_t type = 0;
|
static uint32_t type = 0;
|
||||||
|
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
|
@ -205,7 +201,7 @@ Test(CheckingControlWithAnUnknownTypeIsProgrammerError)
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 5 found in uiControl (this is likely not a real uiControl or some data is corrupt)");
|
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 0 found in uiControl (this is likely not a real uiControl or some data is corrupt)");
|
||||||
uiCheckControlType(uiprivTestHookControlWithInvalidType(), testControlType());
|
uiCheckControlType(uiprivTestHookControlWithInvalidType(), testControlType());
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
@ -214,7 +210,7 @@ Test(CheckingControlWithAnUnknownTypeIsProgrammerErrorEvenIfCheckingAgainstuiCon
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 5 found in uiControl (this is likely not a real uiControl or some data is corrupt)");
|
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 0 found in uiControl (this is likely not a real uiControl or some data is corrupt)");
|
||||||
uiCheckControlType(uiprivTestHookControlWithInvalidType(), uiControlType());
|
uiCheckControlType(uiprivTestHookControlWithInvalidType(), uiControlType());
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
@ -224,9 +220,9 @@ Test(CheckingForUnknownControlTypeIsProgrammerError)
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 5 requested");
|
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 0 requested");
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
uiCheckControlType(c, 5);
|
uiCheckControlType(c, 0);
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
@ -256,8 +252,8 @@ Test(NewControlOfUnknownTypeIsProgrammerError)
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiNewControl(): unknown uiControl type 5 requested");
|
ctx = beginCheckProgrammerError("uiNewControl(): unknown uiControl type 0 requested");
|
||||||
uiNewControl(5, NULL);
|
uiNewControl(0, NULL);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue