Refined the init tests slightly, started a new model for the QueueMain tests, and allowed tests to run for now.

This commit is contained in:
Pietro Gagliardi 2020-05-09 20:03:51 -04:00
parent 73afdaaeb2
commit bbae57ea29
1 changed files with 29 additions and 18 deletions

View File

@ -5,7 +5,7 @@
// TODO test the number of calls to queued functions made // TODO test the number of calls to queued functions made
static void testImplInitFailure(void) static void testImplInitFailureFull(const char *file, long line)
{ {
uiInitError err; uiInitError err;
void *ctx; void *ctx;
@ -15,28 +15,32 @@ static void testImplInitFailure(void)
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() succeeded; expected failure"); TestErrorfFull(file, line, "uiInit() succeeded; expected failure");
else if (strcmp(err.Message, "general failure") != 0) else if (strcmp(err.Message, "general failure") != 0)
TestErrorf("uiInit() failed with wrong message:" diff("%s"), TestErrorfFull(file, line, "uiInit() failed with wrong message:" diff("%s"),
err.Message, "general failure"); err.Message, "general failure");
endCheckProgrammerError(ctx); endCheckProgrammerError(ctx);
} }
#define testImplInitFailure() testImplInitFailureFull(__FILE__, __LINE__)
TestNoInit(InitFailure) TestNoInit(InitFailure)
{ {
testImplInitFailure(); testImplInitFailure();
} }
static void testImplNonNullOptions(void) static void testImplNonNullOptionsFull(const char *file, long line)
{ {
void *ctx; void *ctx;
ctx = beginCheckProgrammerError("uiInit(): invalid uiInitOptions passed"); ctx = beginCheckProgrammerError("uiInit(): invalid uiInitOptions passed");
if (uiInit(ctx, NULL)) if (uiInit(ctx, NULL))
TestErrorf("uiInit() with non-NULL options succeeded; expected failure"); TestErrorfFull(file, line, "uiInit() with non-NULL options succeeded; expected failure");
endCheckProgrammerError(ctx); endCheckProgrammerError(ctx);
} }
#define testImplNonNullOptions() testImplNonNullOptionsFull(__FILE__, __LINE__)
TestNoInit(InitWithNonNullOptionsIsProgrammerError) TestNoInit(InitWithNonNullOptionsIsProgrammerError)
{ {
testImplNonNullOptions(); testImplNonNullOptions();
@ -175,18 +179,25 @@ Test(QueueMain)
// TODOTODOTODOTODOTODOTODOTODOTODOTODOTODO // TODOTODOTODOTODOTODOTODOTODOTODOTODOTODO
#if 0 struct queuedOrder {
int calls[4];
int i;
unsigned int extraCalls;
};
// TODO there has to be a way to do this that absolutely will not possibly go in the wrong order... or produce a false positive static void queueOrder(struct queuedOrder *q, int n)
#define queueOp(name, expr) \ {
static void name(void *data) \ if (q->i < 4) {
{ \ q->calls[q->i] = n;
struct testParams *p = (struct testParams *) data; \ q->i++;
p->flag = p->flag expr; \ return;
} }
queueOp(sub2, - 2) q->extraCalls++;
queueOp(div3, / 3) if (q->extraCalls > 9)
queueOp(mul8, * 8) q->extraCalls = 9;
}
#if 0
static void done(void *data) static void done(void *data)
{ {
@ -234,7 +245,7 @@ static void checkOrderFull(const char *file, long line, uint32_t flag)
#define checkOrder(flag) checkOrderFull(__FILE__, __LINE__, flag) #define checkOrder(flag) checkOrderFull(__FILE__, __LINE__, flag)
Test(QueueMain_Sequence) TODOTest(QueueMain_Sequence)
{ {
struct testParams p; struct testParams p;
@ -254,7 +265,7 @@ static void queueThread(void *data)
uiQueueMain(queued, p); uiQueueMain(queued, p);
} }
Test(QueueMain_DifferentThread) TODOTest(QueueMain_DifferentThread)
{ {
threadThread *thread; threadThread *thread;
threadSysError err; threadSysError err;
@ -284,7 +295,7 @@ static void queueOrderThread(void *data)
queueOrder(p); queueOrder(p);
} }
Test(QueueMain_DifferentThreadSequence) TODOTest(QueueMain_DifferentThreadSequence)
{ {
threadThread *thread; threadThread *thread;
threadSysError err; threadSysError err;