summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-11-14 15:57:04 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-11-14 15:57:04 -0500
commit4075c64ecb5a1f87ff5a324be9d43349f947ce62 (patch)
tree87b6714348cc7b9db00a8e7db08209d7714326f6
parente90e0e00be3bacadfecbd706d7943286c51fe840 (diff)
pke-test: FontTypeIndex -> FontTypeHandle
-rw-r--r--tests/pke-test-font.cpp39
-rw-r--r--tests/pke-test-load-unload.cpp3
-rw-r--r--tests/pke-test-serialization.cpp24
3 files changed, 25 insertions, 41 deletions
diff --git a/tests/pke-test-font.cpp b/tests/pke-test-font.cpp
index 620715d..3f299e4 100644
--- a/tests/pke-test-font.cpp
+++ b/tests/pke-test-font.cpp
@@ -6,7 +6,6 @@
#include "font.hpp"
#include "pk.h"
#include "pke-test-stubs.h"
-#include "pke-test-types.h"
#include "thread-pool.hpp"
static pk_membucket *bkt;
@@ -37,35 +36,32 @@ void pke_test_font_teardown() {
/* Ensure the font exists
*/
int pke_test_font_001() {
- int err_index = 0;
-
- FontType *ft = FontType_Get(FontTypeIndex{0});
- PKE_TEST_ASSERT(ft != nullptr, err_index);
- PKE_TEST_ASSERT(ft->index_ft == FontTypeIndex{0}, err_index);
-
+ FontType *ft = FontType_Get({0,0});
+ PK_TEST_ASSERT_NEQ_RET(nullptr, ft);
return 0;
}
/* Ensure we can have more than one FontRender
*/
int pke_test_font_002() {
- int err_index = 0;
- FontTypeIndex fti{0};
+ FontTypeHandle fti{};
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.handle_fr.b == 0u, err_index);
- PKE_TEST_ASSERT(handle_001.handle_fr.i == 0u, err_index);
+ PK_TEST_ASSERT_EQ_RET(0u, handle_001.font_type_handle.b);
+ PK_TEST_ASSERT_EQ_RET(0u, handle_001.font_type_handle.i);
+ PK_TEST_ASSERT_EQ_RET(0u, handle_001.font_render_handle.b);
+ PK_TEST_ASSERT_EQ_RET(0u, handle_001.font_render_handle.i);
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.handle_fr.b == 0u, err_index);
- PKE_TEST_ASSERT(handle_002.handle_fr.i == 1u, err_index);
+ PK_TEST_ASSERT_EQ_RET(0u, handle_002.font_type_handle.b);
+ PK_TEST_ASSERT_EQ_RET(0u, handle_002.font_type_handle.i);
+ PK_TEST_ASSERT_EQ_RET(0u, handle_002.font_render_handle.b);
+ PK_TEST_ASSERT_EQ_RET(1u, handle_002.font_render_handle.i);
return 0;
}
@@ -75,22 +71,23 @@ int pke_test_font_002() {
int pke_test_font_003() {
unsigned short u;
const unsigned short count = 96;
- FontTypeIndex fti{0};
+ FontTypeHandle fti{0,0};
FontTypeRender handles[count];
FontRenderSettings frs{};
for (u = 0; u < count; ++u) {
- handles[u].index_ft = FontTypeIndex{0};
- handles[u].handle_fr = {0,0};
+ handles[u].font_type_handle = {0,0};
+ handles[u].font_render_handle = {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);
+ PK_TEST_ASSERT_EQ_RET(0u, handles[u].font_type_handle.b);
+ PK_TEST_ASSERT_EQ_RET(0u, handles[u].font_type_handle.i);
+ PK_TEST_ASSERT_EQ_RET(floor(u / (float)PK_BKT_ARR_HANDLE_I_MAX), handles[u].font_render_handle.b);
+ PK_TEST_ASSERT_EQ_RET(u % PK_BKT_ARR_HANDLE_I_MAX, handles[u].font_render_handle.i);
}
return 0;
diff --git a/tests/pke-test-load-unload.cpp b/tests/pke-test-load-unload.cpp
index 27c588a..ccd3fa4 100644
--- a/tests/pke-test-load-unload.cpp
+++ b/tests/pke-test-load-unload.cpp
@@ -7,7 +7,6 @@
#include "ecs.hpp"
#include "entities.hpp"
#include "game-settings.hpp"
-#include "game.hpp"
#include "level.hpp"
#include "physics.hpp"
#include "pke-test-stubs.h"
@@ -143,7 +142,7 @@ int pke_test_load_unload_do_thing_002(int iteration) {
pkeSettings.rt.nextLevel = level_01;
pke_ui_box *bx = pke_ui_box_new_root(PKE_UI_BOX_TYPE_TEXT);
FontRenderSettings frs_01{};
- bx->type_data->text.font_type_render = FontType_AddStringRender(FontTypeIndex{0}, std::move(cstring_to_pk_cstr("one")), &frs_01, bx);
+ bx->type_data->text.font_type_render = FontType_AddStringRender({0,0}, std::move(cstring_to_pk_cstr("one")), &frs_01, bx);
bx->flags |= PKE_UI_BOX_FLAG_POSITION_TYPE_STATIC;
pke_level_register_root_ui_box(level_01, bx);
diff --git a/tests/pke-test-serialization.cpp b/tests/pke-test-serialization.cpp
index 021b659..0a77a56 100644
--- a/tests/pke-test-serialization.cpp
+++ b/tests/pke-test-serialization.cpp
@@ -10,7 +10,6 @@
#include "physics.hpp"
#include "pk.h"
#include "pke-test-stubs.h"
-#include "pke-test-types.h"
#include "scene.hpp"
#include "serialization-component.hpp"
#include "serialization.hpp"
@@ -455,7 +454,6 @@ int pke_test_serialization_003() {
try {
h = pke_serialize_init(bkt);
- uint64_t idx_unused;
FontRenderSettings frs;
frs.char_scale = 1.0;
frs.char_spacing_scale = 1.0;
@@ -464,7 +462,7 @@ int pke_test_serialization_003() {
frs.surface_area_pos = glm::ivec2(0, 0);
frs.surface_area_type_flags = FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_CENTER_BOTH;
frs.flags = FONT_RENDER_FLAG_NONE;
- FontTypeRender fr_handle = FontType_AddStringRender(FontType_GetFonts(idx_unused)[0].index_ft, std::move(cstring_to_pk_cstr("asdf")), &frs, nullptr, uuid_n[1]);
+ FontTypeRender fr_handle = FontType_AddStringRender({0,0}, std::move(cstring_to_pk_cstr("asdf")), &frs, nullptr, uuid_n[1]);
pke_ui_box *ui_box = pke_ui_box_new_root(PKE_UI_BOX_TYPE_TEXT, uuid_n[2]);
ui_box->flags |= PKE_UI_BOX_FLAG_POSITION_TYPE_DYNAMIC;
@@ -553,12 +551,8 @@ int pke_test_deserialization_103() {
pke_deserialize_scene(h);
- uint64_t idx_unused;
- FontType *fonts = FontType_GetFonts(idx_unused);
- PK_TEST_ASSERT_NEQ_RET(nullptr, fonts);
- PK_TEST_ASSERT_NEQ_RET(0xFFFFFFFFFFFFFFFF, idx_unused);
- // PK_TEST_ASSERT_LTE_RET(0, fonts->renders.head_r.i); // always true, unsigned
- FontRender *fr = &fonts[0].renders[{0,0}];
+ pk_bkt_arr_t<FontType> ft_bkt = *static_cast<pk_bkt_arr_t<FontType>*>(FontType_GetFonts());
+ FontRender *fr = &ft_bkt[{0,0}].renders[{0,0}];
PK_TEST_ASSERT_EQ_RET(1.f, fr->settings.char_scale);
PK_TEST_ASSERT_EQ_RET(1.f, fr->settings.line_height_scale);
@@ -800,7 +794,6 @@ TextBegin::
:PKFE:)VOGON";
int pke_test_serialization_005() {
- int64_t err_index = 0;
uint32_t i, k;
srlztn_serialize_helper *h = nullptr;
pke_kve *kve = nullptr;
@@ -808,7 +801,6 @@ int pke_test_serialization_005() {
try {
h = pke_serialize_init(bkt);
- uint64_t idx_unused;
FontRenderSettings frs;
frs.char_scale = 1.0;
frs.char_spacing_scale = 1.0;
@@ -817,7 +809,7 @@ int pke_test_serialization_005() {
frs.surface_area_pos = glm::ivec2(0, 0);
frs.surface_area_type_flags = FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_CENTER_BOTH;
frs.flags = FONT_RENDER_FLAG_NONE;
- FontType_AddStringRender(FontType_GetFonts(idx_unused)[0].index_ft, cstring_to_pk_cstr(""), &frs, nullptr, uuid_n[1]);
+ FontType_AddStringRender({0,0}, cstring_to_pk_cstr(""), &frs, nullptr, uuid_n[1]);
pke_serialize_scene(h);
pke_serialize_scene_to_stream(ss, h);
@@ -883,12 +875,8 @@ int pke_test_deserialization_105() {
pke_deserialize_scene(h);
- uint64_t idx_unused;
- FontType *fonts = FontType_GetFonts(idx_unused);
- PK_TEST_ASSERT_NEQ_RET(nullptr, fonts);
- PK_TEST_ASSERT_NEQ_RET(0xFFFFFFFFFFFFFFFF, idx_unused);
- // PK_TEST_ASSERT_LTE_RET(fonts->renders.head_r.i > 0u, err_index); // always true, unsigned
- FontRender *fr = &fonts[0].renders[{0,0}];
+ pk_bkt_arr_t<FontType> ft_bkt = *static_cast<pk_bkt_arr_t<FontType>*>(FontType_GetFonts());
+ FontRender *fr = &ft_bkt[{0,0}].renders[{0,0}];
PK_TEST_ASSERT_EQ_RET(1.f, fr->settings.char_scale);
PK_TEST_ASSERT_EQ_RET(1.f, fr->settings.line_height_scale);