Reworked programmer error tests to limit what they catch. The cycle checking tests now correctly crash and burn because the programmer errors they throw are elsewhere. Now to actually hook up the cycle checking! Also added some notes to test/errors.c to explain what we're doing and also fixed the build.
This commit is contained in:
parent
fdf9a1245d
commit
b1d733e9a2
|
@ -192,6 +192,7 @@ void uiControlFree(uiControl *c)
|
||||||
|
|
||||||
static bool parentHasCycle(uiControl *c, uiControl *parent)
|
static bool parentHasCycle(uiControl *c, uiControl *parent)
|
||||||
{
|
{
|
||||||
|
// TODO remember if this is the correct way to use a local uiprivArray
|
||||||
uiprivArray parents;
|
uiprivArray parents;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -202,17 +203,17 @@ static bool parentHasCycle(uiControl *c, uiControl *parent)
|
||||||
|
|
||||||
uiprivArrayInit(parents, uiControl *, 16, "uiControl parent list");
|
uiprivArrayInit(parents, uiControl *, 16, "uiControl parent list");
|
||||||
// add these now, as they are counted as part of any cycles
|
// add these now, as they are counted as part of any cycles
|
||||||
*((uiControl *) uiprivArrayAppend(parents, 1)) = c;
|
*((uiControl **) uiprivArrayAppend(&parents, 1)) = c;
|
||||||
*((uiControl *) uiprivArrayAppend(parents, 1)) = parent;
|
*((uiControl **) uiprivArrayAppend(&parents, 1)) = parent;
|
||||||
for (c = parent->parent; c != NULL; c = c->parent) {
|
for (c = parent->parent; c != NULL; c = c->parent) {
|
||||||
// TODO this doesn't need to be sequential, but I don't imagine this list will ever be long enough to make it matter... yet
|
// TODO this doesn't need to be sequential, but I don't imagine this list will ever be long enough to make it matter... yet
|
||||||
for (i = 0; i < parents.len; i++)
|
for (i = 0; i < parents.len; i++)
|
||||||
if (c == uiprivArrayAt(parents, uiControl *, i)) {
|
if (c == *uiprivArrayAt(parents, uiControl *, i)) {
|
||||||
uiprivArrayFree(parents);
|
uiprivArrayFree(parents);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// new parent; mark it as visited
|
// new parent; mark it as visited
|
||||||
*((uiControl *) uiprivArrayAppend(parents, 1)) = c;
|
*((uiControl **) uiprivArrayAppend(&parents, 1)) = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiprivArrayFree(parents);
|
uiprivArrayFree(parents);
|
||||||
|
|
104
test/controls.c
104
test/controls.c
|
@ -216,37 +216,51 @@ Test(NullControlOSVtableIsProgrammerError)
|
||||||
|
|
||||||
Test(CheckingNullControlIsProgrammerError)
|
Test(CheckingNullControlIsProgrammerError)
|
||||||
{
|
{
|
||||||
|
uint32_t ctrlType;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
|
ctrlType = uiControlType();
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): invalid null pointer for uiControl");
|
ctx = beginCheckProgrammerError("uiCheckControlType(): invalid null pointer for uiControl");
|
||||||
uiCheckControlType(NULL, uiControlType());
|
uiCheckControlType(NULL, ctrlType);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(CheckingNonControlIsProgrammerError)
|
Test(CheckingNonControlIsProgrammerError)
|
||||||
{
|
{
|
||||||
|
uiControl *c;
|
||||||
|
uint32_t ctrlType;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
|
c = uiprivTestHookControlWithInvalidControlMarker();
|
||||||
|
ctrlType = uiControlType();
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): object passed in not a uiControl");
|
ctx = beginCheckProgrammerError("uiCheckControlType(): object passed in not a uiControl");
|
||||||
uiCheckControlType(uiprivTestHookControlWithInvalidControlMarker(), uiControlType());
|
uiCheckControlType(c, ctrlType);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(CheckingControlWithAnUnknownTypeIsProgrammerError)
|
Test(CheckingControlWithAnUnknownTypeIsProgrammerError)
|
||||||
{
|
{
|
||||||
|
uiControl *c;
|
||||||
|
uint32_t ctrlType;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
|
c = uiprivTestHookControlWithInvalidType();
|
||||||
|
ctrlType = testControlType();
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 0 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(c, ctrlType);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(CheckingControlWithAnUnknownTypeIsProgrammerErrorEvenIfCheckingAgainstuiControlType)
|
Test(CheckingControlWithAnUnknownTypeIsProgrammerErrorEvenIfCheckingAgainstuiControlType)
|
||||||
{
|
{
|
||||||
|
uiControl *c;
|
||||||
|
uint32_t ctrlType;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
|
c = uiprivTestHookControlWithInvalidType();
|
||||||
|
ctrlType = uiControlType();
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 0 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(c, ctrlType);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,31 +269,35 @@ Test(CheckingForUnknownControlTypeIsProgrammerError)
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 0 requested");
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
|
ctx = beginCheckProgrammerError("uiCheckControlType(): unknown uiControl type 0 requested");
|
||||||
uiCheckControlType(c, 0);
|
uiCheckControlType(c, 0);
|
||||||
uiControlFree(c);
|
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
|
uiControlFree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(CheckControlTypeFailsCorrectly)
|
Test(CheckControlTypeFailsCorrectly)
|
||||||
{
|
{
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
|
uint32_t ctrlType;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiCheckControlType(): wrong uiControl type passed: got TestControl, want TestControl2");
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
uiCheckControlType(c, testControlType2());
|
ctrlType = testControlType2();
|
||||||
uiControlFree(c);
|
ctx = beginCheckProgrammerError("uiCheckControlType(): wrong uiControl type passed: got TestControl, want TestControl2");
|
||||||
|
uiCheckControlType(c, ctrlType);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
|
uiControlFree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(NewControlOfTypeControlIsProgrammerError)
|
Test(NewControlOfTypeControlIsProgrammerError)
|
||||||
{
|
{
|
||||||
|
uint32_t ctrlType;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
|
ctrlType = uiControlType();
|
||||||
ctx = beginCheckProgrammerError("uiNewControl(): uiControlType() passed in when specific control type needed");
|
ctx = beginCheckProgrammerError("uiNewControl(): uiControlType() passed in when specific control type needed");
|
||||||
uiNewControl(uiControlType(), NULL);
|
uiNewControl(ctrlType, NULL);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,10 +312,12 @@ Test(NewControlOfUnknownTypeIsProgrammerError)
|
||||||
|
|
||||||
Test(NewControlWithInvalidInitDataIsProgrammerError)
|
Test(NewControlWithInvalidInitDataIsProgrammerError)
|
||||||
{
|
{
|
||||||
|
uint32_t ctrlType;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
|
ctrlType = testControlType();
|
||||||
ctx = beginCheckProgrammerError("uiNewControl(): invalid init data for TestControl");
|
ctx = beginCheckProgrammerError("uiNewControl(): invalid init data for TestControl");
|
||||||
uiNewControl(testControlType(), testControlFailInit);
|
uiNewControl(ctrlType, testControlFailInit);
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,27 +330,23 @@ Test(FreeingNullControlIsProgrammerError)
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO go back through all these tests and make the programmer error check as finely scoped as necessary
|
|
||||||
Test(FreeingParentedControlIsProgrammerError)
|
Test(FreeingParentedControlIsProgrammerError)
|
||||||
{
|
{
|
||||||
uiControl *c, *d;
|
uiControl *c, *d;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiControlFree(): cannot be called on a control with has a parent");
|
|
||||||
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
d = uiNewControl(testControlType(), NULL);
|
d = uiNewControl(testControlType(), NULL);
|
||||||
|
|
||||||
// this should fail
|
|
||||||
uiControlSetParent(c, d);
|
uiControlSetParent(c, d);
|
||||||
|
ctx = beginCheckProgrammerError("uiControlFree(): cannot be called on a control with has a parent");
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
|
||||||
// this should not fail; it's normal cleanup
|
// cleanup
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
uiControlFree(d);
|
uiControlFree(d);
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
|
|
||||||
endCheckProgrammerError(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(SetParentWithNullControlIsProgrammerError)
|
Test(SetParentWithNullControlIsProgrammerError)
|
||||||
|
@ -347,11 +363,11 @@ Test(RemovingParentFromInitiallyParentlessControlIsProgrammerError)
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with no parent to have no parent");
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
|
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with no parent to have no parent");
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
uiControlFree(c);
|
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
|
uiControlFree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(RemovingParentFromExplicitlyParentlessControlIsProgrammerError)
|
Test(RemovingParentFromExplicitlyParentlessControlIsProgrammerError)
|
||||||
|
@ -359,15 +375,15 @@ Test(RemovingParentFromExplicitlyParentlessControlIsProgrammerError)
|
||||||
uiControl *c, *d;
|
uiControl *c, *d;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with no parent to have no parent");
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
d = uiNewControl(testControlType(), NULL);
|
d = uiNewControl(testControlType(), NULL);
|
||||||
uiControlSetParent(c, d);
|
uiControlSetParent(c, d);
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
|
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with no parent to have no parent");
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
uiControlFree(c);
|
|
||||||
uiControlFree(d);
|
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
|
uiControlFree(d);
|
||||||
|
uiControlFree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(ReparentingAlreadyParentedControlToDifferentParentIsProgrammerError)
|
Test(ReparentingAlreadyParentedControlToDifferentParentIsProgrammerError)
|
||||||
|
@ -375,23 +391,20 @@ Test(ReparentingAlreadyParentedControlToDifferentParentIsProgrammerError)
|
||||||
uiControl *c, *d, *e;
|
uiControl *c, *d, *e;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with a parent to have another parent");
|
|
||||||
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
d = uiNewControl(testControlType(), NULL);
|
d = uiNewControl(testControlType(), NULL);
|
||||||
e = uiNewControl(testControlType(), NULL);
|
e = uiNewControl(testControlType(), NULL);
|
||||||
|
|
||||||
// this should fail
|
|
||||||
uiControlSetParent(c, d);
|
uiControlSetParent(c, d);
|
||||||
|
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with a parent to have another parent");
|
||||||
uiControlSetParent(c, e);
|
uiControlSetParent(c, e);
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
|
||||||
// this should not (cleanup)
|
// cleanup
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
uiControlFree(e);
|
uiControlFree(e);
|
||||||
uiControlFree(d);
|
uiControlFree(d);
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
|
|
||||||
endCheckProgrammerError(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(ReparentingAlreadyParentedControlToSameParentIsProgrammerError)
|
Test(ReparentingAlreadyParentedControlToSameParentIsProgrammerError)
|
||||||
|
@ -399,22 +412,18 @@ Test(ReparentingAlreadyParentedControlToSameParentIsProgrammerError)
|
||||||
uiControl *c, *d;
|
uiControl *c, *d;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with a parent to have another parent");
|
|
||||||
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
d = uiNewControl(testControlType(), NULL);
|
d = uiNewControl(testControlType(), NULL);
|
||||||
|
|
||||||
// this should fail
|
|
||||||
uiControlSetParent(c, d);
|
uiControlSetParent(c, d);
|
||||||
|
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot set a control with a parent to have another parent");
|
||||||
uiControlSetParent(c, d);
|
uiControlSetParent(c, d);
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
|
||||||
// this should not (cleanup)
|
// cleanup
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
// TODO make sure all cleanups are in reverse order
|
|
||||||
uiControlFree(d);
|
uiControlFree(d);
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
|
|
||||||
endCheckProgrammerError(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(ControlParentCyclesDisallowed_TwoControls)
|
Test(ControlParentCyclesDisallowed_TwoControls)
|
||||||
|
@ -422,21 +431,19 @@ Test(ControlParentCyclesDisallowed_TwoControls)
|
||||||
uiControl *c, *d;
|
uiControl *c, *d;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("TODO");
|
|
||||||
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
d = uiNewControl(testControlType(), NULL);
|
d = uiNewControl(testControlType(), NULL);
|
||||||
|
|
||||||
// this should fail
|
|
||||||
uiControlSetParent(c, d);
|
uiControlSetParent(c, d);
|
||||||
|
ctx = beginCheckProgrammerError("TODO");
|
||||||
uiControlSetParent(d, c);
|
uiControlSetParent(d, c);
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
|
||||||
// this should not (cleanup)
|
// cleanup
|
||||||
|
// TODO reformat all the other tests to have clear init, test, and cleanup sections, and also maybe remove these "// cleanup" comments
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
uiControlFree(d);
|
uiControlFree(d);
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
|
|
||||||
endCheckProgrammerError(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(ControlParentCyclesDisallowed_ThreeControls)
|
Test(ControlParentCyclesDisallowed_ThreeControls)
|
||||||
|
@ -444,25 +451,22 @@ Test(ControlParentCyclesDisallowed_ThreeControls)
|
||||||
uiControl *c, *d, *e;
|
uiControl *c, *d, *e;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("TODO");
|
|
||||||
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
d = uiNewControl(testControlType(), NULL);
|
d = uiNewControl(testControlType(), NULL);
|
||||||
e = uiNewControl(testControlType(), NULL);
|
e = uiNewControl(testControlType(), NULL);
|
||||||
|
|
||||||
// this should fail
|
|
||||||
uiControlSetParent(c, d);
|
uiControlSetParent(c, d);
|
||||||
uiControlSetParent(d, e);
|
uiControlSetParent(d, e);
|
||||||
|
ctx = beginCheckProgrammerError("TODO");
|
||||||
uiControlSetParent(e, c);
|
uiControlSetParent(e, c);
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
|
||||||
// this should not (cleanup)
|
// cleanup
|
||||||
uiControlSetParent(d, NULL);
|
uiControlSetParent(d, NULL);
|
||||||
uiControlSetParent(c, NULL);
|
uiControlSetParent(c, NULL);
|
||||||
uiControlFree(e);
|
uiControlFree(e);
|
||||||
uiControlFree(d);
|
uiControlFree(d);
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
|
|
||||||
endCheckProgrammerError(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(ControlCannotBeItsOwnParent)
|
Test(ControlCannotBeItsOwnParent)
|
||||||
|
@ -470,11 +474,11 @@ Test(ControlCannotBeItsOwnParent)
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("TODO");
|
|
||||||
c = uiNewControl(testControlType(), NULL);
|
c = uiNewControl(testControlType(), NULL);
|
||||||
|
ctx = beginCheckProgrammerError("TODO");
|
||||||
uiControlSetParent(c, c);
|
uiControlSetParent(c, c);
|
||||||
uiControlFree(c);
|
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
|
uiControlFree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(GettingImplDataOfNullControlIsProgrammerError)
|
Test(GettingImplDataOfNullControlIsProgrammerError)
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
// Do not put any test cases in this file; they will not be run.
|
// Do not put any test cases in this file; they will not be run.
|
||||||
|
|
||||||
|
// Notes on these functions:
|
||||||
|
// - Try to wrap them as tightly around the specific calls being tested as possible, to avoid accidentally catching something else.
|
||||||
|
// - I don't know if these are thread-safe yet (TODO potentially make them so so this first part can be made tighter).
|
||||||
|
|
||||||
struct checkProgrammerErrorParams {
|
struct checkProgrammerErrorParams {
|
||||||
bool caught;
|
bool caught;
|
||||||
char *msgGot;
|
char *msgGot;
|
||||||
|
|
|
@ -8,8 +8,8 @@ static void testImplInitFailureFull(const char *file, long line)
|
||||||
uiInitError err;
|
uiInitError err;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError(NULL);
|
|
||||||
uiprivTestHookSetInitShouldFailArtificially(true);
|
uiprivTestHookSetInitShouldFailArtificially(true);
|
||||||
|
ctx = beginCheckProgrammerError(NULL);
|
||||||
memset(&err, 0, sizeof (uiInitError));
|
memset(&err, 0, sizeof (uiInitError));
|
||||||
err.Size = sizeof (uiInitError);
|
err.Size = sizeof (uiInitError);
|
||||||
if (uiInit(NULL, &err))
|
if (uiInit(NULL, &err))
|
||||||
|
@ -149,28 +149,27 @@ Test(MainCalledTwiceIsProgrammerError)
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiMain(): attempt to call more than once");
|
|
||||||
uiQueueMain(done, NULL);
|
uiQueueMain(done, NULL);
|
||||||
uiMain();
|
uiMain();
|
||||||
|
ctx = beginCheckProgrammerError("uiMain(): attempt to call more than once");
|
||||||
uiMain();
|
uiMain();
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mainAndQuit(void *data)
|
static void mainAndQuit(void *data)
|
||||||
{
|
{
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("uiMain(): attempt to call more than once");
|
||||||
uiMain();
|
uiMain();
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
uiQuit();
|
uiQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(MainCalledRecursivelyIsProgrammerError)
|
Test(MainCalledRecursivelyIsProgrammerError)
|
||||||
{
|
{
|
||||||
void *ctx;
|
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiMain(): attempt to call more than once");
|
|
||||||
uiQueueMain(mainAndQuit, NULL);
|
uiQueueMain(mainAndQuit, NULL);
|
||||||
uiMain();
|
uiMain();
|
||||||
uiMain();
|
|
||||||
endCheckProgrammerError(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// largely redundant due to InitCorrectlyAfterInitializedSuccessfully, but include it anyway just to be safe
|
// largely redundant due to InitCorrectlyAfterInitializedSuccessfully, but include it anyway just to be safe
|
||||||
|
@ -179,9 +178,9 @@ Test(InitAfterMainIsProgrammerError)
|
||||||
uiInitError err;
|
uiInitError err;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiInit(): attempt to call more than once");
|
|
||||||
uiQueueMain(done, NULL);
|
uiQueueMain(done, NULL);
|
||||||
uiMain();
|
uiMain();
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): attempt to call more than once");
|
||||||
memset(&err, 0, sizeof (uiInitError));
|
memset(&err, 0, sizeof (uiInitError));
|
||||||
err.Size = sizeof (uiInitError);
|
err.Size = sizeof (uiInitError);
|
||||||
if (uiInit(NULL, &err))
|
if (uiInit(NULL, &err))
|
||||||
|
@ -200,27 +199,27 @@ Test(QuitBeforeMainIsProgrammerError)
|
||||||
|
|
||||||
static void quitTwice(void *data)
|
static void quitTwice(void *data)
|
||||||
{
|
{
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
uiQuit();
|
uiQuit();
|
||||||
|
ctx = beginCheckProgrammerError("uiQuit(): attempt to call more than once");
|
||||||
uiQuit();
|
uiQuit();
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(QuitCalledTwiceIsProgrammerError)
|
Test(QuitCalledTwiceIsProgrammerError)
|
||||||
{
|
{
|
||||||
void *ctx;
|
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiQuit(): attempt to call more than once");
|
|
||||||
uiQueueMain(quitTwice, NULL);
|
uiQueueMain(quitTwice, NULL);
|
||||||
uiMain();
|
uiMain();
|
||||||
endCheckProgrammerError(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(QuitAfterMainIsProgrammerError)
|
Test(QuitAfterMainIsProgrammerError)
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
|
||||||
ctx = beginCheckProgrammerError("uiQuit(): attempt to call more than once");
|
|
||||||
uiQueueMain(done, NULL);
|
uiQueueMain(done, NULL);
|
||||||
uiMain();
|
uiMain();
|
||||||
|
ctx = beginCheckProgrammerError("uiQuit(): attempt to call more than once");
|
||||||
uiQuit();
|
uiQuit();
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue