Started to fix init/main tests.
This commit is contained in:
parent
514037ba6c
commit
761d3a434a
|
@ -4,44 +4,98 @@
|
||||||
|
|
||||||
// TODO test the number of calls to queued functions made
|
// TODO test the number of calls to queued functions made
|
||||||
|
|
||||||
#define errInvalidOptions "options parameter to uiInit() must be NULL"
|
TestNoInit(InitWithNonNullOptionsIsProgrammerError)
|
||||||
#define errAlreadyInitialized "libui already initialized"
|
|
||||||
|
|
||||||
TestNoInit(Init)
|
|
||||||
{
|
{
|
||||||
uiInitError err;
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): invalid uiInitOptions passed");
|
||||||
|
if (uiInit(ctx, NULL))
|
||||||
|
TestErrorf("uiInit() with non-NULL options succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestNoInit(InitWithNullErrorIsProgrammerError)
|
||||||
|
{
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): invalid null pointer for uiInitError");
|
||||||
if (uiInit(NULL, NULL))
|
if (uiInit(NULL, NULL))
|
||||||
TestErrorf("uiInit() with NULL error succeeded; expected failure");
|
TestErrorf("uiInit() with NULL error succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestNoInit(InitWithWrongErrorSizeIsProgrammerError)
|
||||||
|
{
|
||||||
|
uiInitError err;
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): wrong size 2 for uiInitError");
|
||||||
memset(&err, 0, sizeof (uiInitError));
|
memset(&err, 0, sizeof (uiInitError));
|
||||||
|
|
||||||
err.Size = 2;
|
err.Size = 2;
|
||||||
if (uiInit(NULL, &err))
|
if (uiInit(NULL, &err))
|
||||||
TestErrorf("uiInit() with error with invalid size succeeded; expected failure");
|
TestErrorf("uiInit() with error with invalid size succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
err.Size = sizeof (uiInitError);
|
|
||||||
|
|
||||||
if (uiInit(&err, &err))
|
|
||||||
TestErrorf("uiInit() with non-NULL options succeeded; expected failure");
|
|
||||||
if (strcmp(err.Message, errInvalidOptions) != 0)
|
|
||||||
TestErrorf("uiInit() with non-NULL options returned bad error message:" diff("%s"),
|
|
||||||
err.Message, errInvalidOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(InitAfterInitialized)
|
Test(InitCorrectlyAfterInitializedSuccessfully)
|
||||||
{
|
{
|
||||||
uiInitError err;
|
uiInitError err;
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
|
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))
|
||||||
TestErrorf("uiInit() after a previous successful call succeeded; expected failure");
|
TestFatalf("uiInit() after a previous successful call succeeded; expected failure");
|
||||||
if (strcmp(err.Message, errAlreadyInitialized) != 0)
|
endCheckProgrammerError(ctx);
|
||||||
TestErrorf("uiInit() after a previous successful call returned bad error message:" diff("%s"),
|
|
||||||
err.Message, errAlreadyInitialized);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Test(InitIncorrectlyAfterInitializedSuccessfully)
|
||||||
|
{
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): attempt to call more than once");
|
||||||
|
if (uiInit(NULL, NULL))
|
||||||
|
TestFatalf("bad uiInit() after a previous successful call succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO TestNoInit(InitCorrectlyAfterFailureToInitailize)
|
||||||
|
// TODO TestNoInit(InitIncorrectlyAfterFailureToInitialize)
|
||||||
|
|
||||||
|
TestNoInit(InitCorrectlyAfterIncorrectInitialization)
|
||||||
|
{
|
||||||
|
uiInitError err;
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): invalid uiInitOptions passed");
|
||||||
|
if (uiInit(ctx, NULL))
|
||||||
|
TestErrorf("uiInit() with non-NULL options succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): attempt to call more than once");
|
||||||
|
memset(&err, 0, sizeof (uiInitError));
|
||||||
|
err.Size = sizeof (uiInitError);
|
||||||
|
if (uiInit(NULL, &err))
|
||||||
|
TestFatalf("uiInit() after a previous successful call succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestNoInit(InitIncorrectlyAfterIncorrectInitialization)
|
||||||
|
{
|
||||||
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): invalid uiInitOptions passed");
|
||||||
|
if (uiInit(ctx, NULL))
|
||||||
|
TestErrorf("uiInit() with non-NULL options succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
ctx = beginCheckProgrammerError("uiInit(): attempt to call more than once");
|
||||||
|
if (uiInit(NULL, NULL))
|
||||||
|
TestFatalf("bad uiInit() after a previous successful call succeeded; expected failure");
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODOTODOTODOTODOTODOTODOTODOTODOTODOTODO
|
||||||
|
|
||||||
struct testParams {
|
struct testParams {
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
threadSysError err;
|
threadSysError err;
|
||||||
|
|
|
@ -80,7 +80,7 @@ sharedbitsPrintfFunc(
|
||||||
// errors.c
|
// errors.c
|
||||||
extern void *beginCheckProgrammerError(const char *want);
|
extern void *beginCheckProgrammerError(const char *want);
|
||||||
extern void endCheckProgrammerErrorFull(const char *file, long line, void *context);
|
extern void endCheckProgrammerErrorFull(const char *file, long line, void *context);
|
||||||
#define endCheckProgrammerError(context) checkProgrammerErrorFull(__FILE__, __LINE__, context)
|
#define endCheckProgrammerError(context) endCheckProgrammerErrorFull(__FILE__, __LINE__, context)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue