summaryrefslogtreecommitdiff
path: root/tests/pke-test-font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pke-test-font.cpp')
-rw-r--r--tests/pke-test-font.cpp43
1 files changed, 38 insertions, 5 deletions
diff --git a/tests/pke-test-font.cpp b/tests/pke-test-font.cpp
index a766f26..620715d 100644
--- a/tests/pke-test-font.cpp
+++ b/tests/pke-test-font.cpp
@@ -51,25 +51,53 @@ int pke_test_font_001() {
int pke_test_font_002() {
int err_index = 0;
FontTypeIndex fti{0};
- FontRenderHandle handle_001{};
- FontRenderHandle handle_002{};
+ FontTypeRender handle_001{};
+ FontTypeRender handle_002{};
FontRenderSettings frs{};
handle_001 = FontType_AddStringRender(fti, std::move(cstring_to_pk_cstr("string one")), &frs);
PKE_TEST_ASSERT(handle_001.index_ft == FontTypeIndex{0}, err_index);
- PKE_TEST_ASSERT(handle_001.index_fr == FontRenderIndex{0}, err_index);
+ PKE_TEST_ASSERT(handle_001.handle_fr.b == 0u, err_index);
+ PKE_TEST_ASSERT(handle_001.handle_fr.i == 0u, err_index);
handle_002 = FontType_AddStringRender(fti, std::move(cstring_to_pk_cstr("string two")), &frs);
PKE_TEST_ASSERT(handle_002.index_ft == FontTypeIndex{0}, err_index);
- PKE_TEST_ASSERT(handle_002.index_fr == FontRenderIndex{1}, err_index);
+ PKE_TEST_ASSERT(handle_002.handle_fr.b == 0u, err_index);
+ PKE_TEST_ASSERT(handle_002.handle_fr.i == 1u, err_index);
+
+ return 0;
+}
+
+/* Ensure we can have a lot of FontRenders
+ */
+int pke_test_font_003() {
+ unsigned short u;
+ const unsigned short count = 96;
+ FontTypeIndex fti{0};
+ FontTypeRender handles[count];
+ FontRenderSettings frs{};
+
+ for (u = 0; u < count; ++u) {
+ handles[u].index_ft = FontTypeIndex{0};
+ handles[u].handle_fr = {0,0};
+ }
+
+ for (u = 0; u < count; ++u) {
+ char *s = (char*)malloc(64);
+ snprintf(s, 1024, "%s - %u", "test", u);
+ handles[u] = FontType_AddStringRender(fti, std::move(cstring_to_pk_cstr(s)), &frs);
+ PK_TEST_ASSERT_EQ_RET((FontTypeIndex_T)FontTypeIndex{0}, (FontTypeIndex_T)handles[u].index_ft);
+ PK_TEST_ASSERT_EQ_RET(floor(u / (float)PK_BKT_ARR_HANDLE_I_MAX), handles[u].handle_fr.b);
+ PK_TEST_ASSERT_EQ_RET(u % PK_BKT_ARR_HANDLE_I_MAX, handles[u].handle_fr.i);
+ }
return 0;
}
struct pk_test_group *pke_test_font_get_group() {
- static const uint64_t test_count = 2;
+ static const uint64_t test_count = 3;
static struct pk_test tests[test_count] = {
{
.title = "test 001",
@@ -81,6 +109,11 @@ struct pk_test_group *pke_test_font_get_group() {
.func = pke_test_font_002,
.expected_result = 0,
},
+ {
+ .title = "test 003",
+ .func = pke_test_font_003,
+ .expected_result = 0,
+ },
};
static struct pk_test_group group = {};
group.title = "font test";