/** * Copyright (c) 2026 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "dusktest.h" #include "ui/widget/uitab.h" #include "util/memory.h" // uiTabInit requires a real font (FONT_DEFAULT) to build the label's // glyph cache, which needs a live GL context this test binary doesn't // have. uiTabRebuildBackground only reads the label's already-measured // width/height, so it's safe to set those directly and exercise it here. static void test_uiTabRebuildBackground_matchesLabelSize(void **state) { uitab_t tab; memoryZero(&tab, sizeof(uitab_t)); tab.label.width = 42; tab.label.height = 12; uiTabRebuildBackground(&tab); assert_float_equal(tab.cachedBackground.min[0], 0.0f, 0.0001f); assert_float_equal(tab.cachedBackground.min[1], 0.0f, 0.0001f); assert_float_equal(tab.cachedBackground.max[0], 42.0f, 0.0001f); assert_float_equal(tab.cachedBackground.max[1], 12.0f, 0.0001f); } int main(int argc, char **argv) { const struct CMUnitTest tests[] = { cmocka_unit_test(test_uiTabRebuildBackground_matchesLabelSize), }; return cmocka_run_group_tests(tests, NULL, NULL); }