#include "font/BitmapFont2.h" #include "unittest/TestSuite.h" #include "stem_core.h" static void testInit(void) { BitmapFont2 * font = BitmapFont2_create(0, NULL, 0, NULL, 0.0f, 0.0f, 0.0f, 0.0f); TestCase_assertPointerNonNULL(font); TestCase_assertUIntEqual(font->characterCount, 0); TestCase_assertPointerNULL(font->characters); TestCase_assertUIntEqual(font->kernCount, 0); TestCase_assertPointerNULL(font->kerns); TestCase_assertFloatEqual(font->height, 0.0f); TestCase_assertFloatEqual(font->initialAdvance, 0.0f); TestCase_assertFloatEqual(font->terminatingAdvance, 0.0f); TestCase_assertFloatEqual(font->tabWidth, 0.0f); BitmapFont2_dispose(font); BitmapFont2_character characters[] = { {0, NULL, 1.0f, {2.0f, 3.0f}, {4.0f, 5.0f}, false, {6.0f, 7.0f, 8.0f, 9.0f}}, {1, NULL, 2.0f, {3.0f, 4.0f}, {5.0f, 6.0f}, true, {10.0f, 11.0f, 12.0f, 13.0f}} }; BitmapFont2_kern kerns[] = { {0, 1, 2.0f} }; font = BitmapFont2_create(sizeof_count(characters), characters, sizeof_count(kerns), kerns, 10.0f, 3.0f, 4.0f, 20.0f); TestCase_assertPointerNonNULL(font); TestCase_assertUIntEqual(font->characterCount, sizeof_count(characters)); TestCase_assertPointerNonNULL(font->characters); TestCase_assertPointerUnequal(font->characters, characters); TestCase_assertUIntEqual(font->characters[0].codepoint, 0); TestCase_assertFloatEqual(font->characters[0].advance, 1.0f); TestCase_assertFloatEqual(font->characters[0].glyphOffset.x, 2.0f); TestCase_assertFloatEqual(font->characters[0].glyphOffset.y, 3.0f); TestCase_assertFloatEqual(font->characters[0].glyphSize.x, 4.0f); TestCase_assertFloatEqual(font->characters[0].glyphSize.y, 5.0f); TestCase_assertBoolFalse(font->characters[0].fixedColor); TestCase_assertFloatEqual(font->characters[0].atlasEntry.xMin, 6.0f); TestCase_assertFloatEqual(font->characters[0].atlasEntry.xMax, 7.0f); TestCase_assertFloatEqual(font->characters[0].atlasEntry.yMin, 8.0f); TestCase_assertFloatEqual(font->characters[0].atlasEntry.yMax, 9.0f); TestCase_assertUIntEqual(font->characters[1].codepoint, 1); TestCase_assertFloatEqual(font->characters[1].advance, 2.0f); TestCase_assertFloatEqual(font->characters[1].glyphOffset.x, 3.0f); TestCase_assertFloatEqual(font->characters[1].glyphOffset.y, 4.0f); TestCase_assertFloatEqual(font->characters[1].glyphSize.x, 5.0f); TestCase_assertFloatEqual(font->characters[1].glyphSize.y, 6.0f); TestCase_assertBoolTrue(font->characters[1].fixedColor); TestCase_assertFloatEqual(font->characters[1].atlasEntry.xMin, 10.0f); TestCase_assertFloatEqual(font->characters[1].atlasEntry.xMax, 11.0f); TestCase_assertFloatEqual(font->characters[1].atlasEntry.yMin, 12.0f); TestCase_assertFloatEqual(font->characters[1].atlasEntry.yMax, 13.0f); TestCase_assertUIntEqual(font->kernCount, 1); TestCase_assertPointerNonNULL(font->kerns); TestCase_assertPointerUnequal(font->kerns, kerns); TestCase_assertUIntEqual(font->kerns[0].codepoint1, 0); TestCase_assertUIntEqual(font->kerns[0].codepoint2, 1); TestCase_assertFloatEqual(font->kerns[0].offset, 2.0f); TestCase_assertFloatEqual(font->height, 10.0f); TestCase_assertFloatEqual(font->initialAdvance, 3.0f); TestCase_assertFloatEqual(font->terminatingAdvance, 4.0f); TestCase_assertFloatEqual(font->tabWidth, 20.0f); BitmapFont2_dispose(font); } TEST_SUITE(BitmapFont2Test, testInit)