Added more test cases. Also more TODOs in testing_testing.c.
This commit is contained in:
parent
6c29932efe
commit
4179ff86c2
|
@ -27,15 +27,86 @@ static void freeOpenType(void *otf)
|
|||
testingTest(OpenTypeFeaturesAddGet)
|
||||
{
|
||||
uiOpenTypeFeatures *otf;
|
||||
int got;
|
||||
uint32_t value;
|
||||
|
||||
otf = uiNewOpenTypeFeatures();
|
||||
testingTDefer(t, freeOpenType, otf);
|
||||
uiOpenTypeFeaturesAdd(otf, 'a', 'b', 'c', 'd', 12345);
|
||||
if (!uiOpenTypeFeaturesGet(otf, 'a', 'b', 'c', 'd', &value))
|
||||
testingTFatalf(t, "uiOpenTypeFeaturesGet() failed to get feature we added");
|
||||
got = uiOpenTypeFeaturesGet(otf, 'a', 'b', 'c', 'd', &value);
|
||||
|
||||
if (!got)
|
||||
testingTErrorf(t, "uiOpenTypeFeaturesGet() failed to get feature we added");
|
||||
else if (value != 12345)
|
||||
testingTErrorf(t, "feature abcd: got %" PRIu32 ", want 12345", value);
|
||||
}
|
||||
|
||||
testingTest(OpenTypeFeaturesRemove)
|
||||
{
|
||||
uiOpenTypeFeatures *otf;
|
||||
uint32_t value;
|
||||
|
||||
otf = uiNewOpenTypeFeatures();
|
||||
testingTDefer(t, freeOpenType, otf);
|
||||
uiOpenTypeFeaturesAdd(otf, 'a', 'b', 'c', 'd', 12345);
|
||||
uiOpenTypeFeaturesRemove(otf, 'a', 'b', 'c', 'd');
|
||||
|
||||
if (uiOpenTypeFeaturesGet(otf, 'a', 'b', 'c', 'd', &value))
|
||||
testingTErrorf(t, "uiOpenTypeFeaturesGet() succeeded in getting deleted feature; value %" PRIu32, value);
|
||||
}
|
||||
|
||||
testingTest(OpenTypeFeaturesCloneAdd)
|
||||
{
|
||||
uiOpenTypeFeatures *otf, *otf2;
|
||||
uint32_t value;
|
||||
|
||||
otf = uiNewOpenTypeFeatures();
|
||||
testingTDefer(t, freeOpenType, otf);
|
||||
uiOpenTypeFeaturesAdd(otf, 'a', 'b', 'c', 'd', 12345);
|
||||
otf2 = uiOpenTypeFeaturesClone(otf);
|
||||
testingTDefer(t, freeOpenType, otf2);
|
||||
uiOpenTypeFeaturesAdd(otf2, 'q', 'w', 'e', 'r', 56789);
|
||||
|
||||
if (uiOpenTypeFeaturesGet(otf, 'q', 'w', 'e', 'r', &value))
|
||||
testingTErrorf(t, "uiOpenTypeFeaturesGet() on original succeeded in getting feature added to clone; value %" PRIu32, value);
|
||||
}
|
||||
|
||||
testingTest(OpenTypeFeaturesCloneModify)
|
||||
{
|
||||
uiOpenTypeFeatures *otf, *otf2;
|
||||
uint32_t value;
|
||||
|
||||
otf = uiNewOpenTypeFeatures();
|
||||
testingTDefer(t, freeOpenType, otf);
|
||||
uiOpenTypeFeaturesAdd(otf, 'a', 'b', 'c', 'd', 12345);
|
||||
otf2 = uiOpenTypeFeaturesClone(otf);
|
||||
testingTDefer(t, freeOpenType, otf2);
|
||||
uiOpenTypeFeaturesAdd(otf2, 'a', 'b', 'c', 'd', 56789);
|
||||
|
||||
uiOpenTypeFeaturesGet(otf, 'a', 'b', 'c', 'd', &value);
|
||||
if (value != 12345)
|
||||
testingTFatalf(t, "feature abcd: got %" PRIu32 ", want 12345", value);
|
||||
testingTErrorf(t, "uiOpenTypeFeaturesGet() on original: got %" PRIu32 ", want 12345", value);
|
||||
uiOpenTypeFeaturesGet(otf2, 'a', 'b', 'c', 'd', &value);
|
||||
if (value != 56789)
|
||||
testingTErrorf(t, "uiOpenTypeFeaturesGet() on clone: got %" PRIu32 ", want 56789", value);
|
||||
}
|
||||
|
||||
testingTest(OpenTypeFeaturesCloneRemove)
|
||||
{
|
||||
uiOpenTypeFeatures *otf, *otf2;
|
||||
uint32_t value;
|
||||
|
||||
otf = uiNewOpenTypeFeatures();
|
||||
testingTDefer(t, freeOpenType, otf);
|
||||
uiOpenTypeFeaturesAdd(otf, 'a', 'b', 'c', 'd', 12345);
|
||||
otf2 = uiOpenTypeFeaturesClone(otf);
|
||||
testingTDefer(t, freeOpenType, otf2);
|
||||
uiOpenTypeFeaturesRemove(otf2, 'a', 'b', 'c', 'd');
|
||||
|
||||
if (uiOpenTypeFeaturesGet(otf2, 'a', 'b', 'c', 'd', &value))
|
||||
testingTErrorf(t, "uiOpenTypeFeaturesGet() on clone succeeded in getting feature removed from clone; value %" PRIu32, value);
|
||||
if (!uiOpenTypeFeaturesGet(otf, 'a', 'b', 'c', 'd', &value))
|
||||
testingTErrorf(t, "uiOpenTypeFeaturesGet() on original failed to get feature removed from clone");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
|
|
@ -36,6 +36,7 @@ void testingprivRegisterTest(const char *name, void (*f)(testingT *))
|
|||
t->skipped = 0;
|
||||
t->defers = NULL;
|
||||
t->defersRun = 0;
|
||||
// TODO add in the order called
|
||||
t->next = tests;
|
||||
tests = t;
|
||||
}
|
||||
|
@ -137,6 +138,7 @@ void testingTDefer(testingT *t, void (*f)(void *data), void *data)
|
|||
d = testingprivNew(struct defer);
|
||||
d->f = f;
|
||||
d->data = data;
|
||||
// add to the head of the list so defers are run in reverse order of how they were added
|
||||
d->next = t->defers;
|
||||
t->defers = d;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue