summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-06-05 10:50:24 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-06-05 10:50:24 -0400
commit55c518b2922a2d8a41212a952a68c17c7c9a3f8b (patch)
tree31cc135bc18bf11893d5ca3bca47c9ee27bf141f /tests
parentb0b1159780311c7c8ca9a9d41d11794e91e8895c (diff)
pk.h: update to 0.6.0 + handle breaking changes
Diffstat (limited to 'tests')
-rw-r--r--tests/pke-test-dummy.cpp41
-rw-r--r--tests/pke-test-serialization.cpp55
-rw-r--r--tests/pke-test.cpp10
3 files changed, 72 insertions, 34 deletions
diff --git a/tests/pke-test-dummy.cpp b/tests/pke-test-dummy.cpp
index a7e2ddc..0caa865 100644
--- a/tests/pke-test-dummy.cpp
+++ b/tests/pke-test-dummy.cpp
@@ -1,18 +1,55 @@
#include "./pke-test-dummy.h"
+#include "asset-manager.hpp"
+#include "camera.hpp"
+#include "ecs.hpp"
+#include "physics.hpp"
+#include "scene.hpp"
+#include "static-ui.hpp"
+#include "thread-pool.hpp"
+
int pke_test_dummy_001() {
+ Physics_Init();
+ PkeThreads_Init();
+ AM_Init();
+ ECS_Init();
+ pke_ui_init();
+ PkeCamera_Init();
+ FontType_Init();
+ pke_scene_master_init();
+ /* do thing */
+ /*
+ {
+ AssetHandle h = AM_GetHandle(AssetKey {"fnt_mquin_gly"});
+ AM_Get(h);
+ AM_Release(h);
+ }
+ */
+ pke_scene_master_teardown();
+ FontType_Teardown();
+ PkeCamera_Teardown();
+ pke_ui_teardown();
+ ECS_Teardown();
+ AM_Teardown();
+ PkeThreads_Teardown();
+ Physics_Teardown();
return 0;
}
struct pke_test_group *pke_test_dummy_get_group() {
- static const uint64_t test_count = 1;
+ static const uint64_t test_count = 2;
static struct pke_test tests[test_count] = {
{
.title = "test 001",
.func = pke_test_dummy_001,
.expected_result = 0,
- }
+ },
+ {
+ .title = "test 002",
+ .func = pke_test_dummy_001,
+ .expected_result = 0,
+ },
};
static struct pke_test_group group = {};
group.title = "dummy test";
diff --git a/tests/pke-test-serialization.cpp b/tests/pke-test-serialization.cpp
index 536d6c1..c24faca 100644
--- a/tests/pke-test-serialization.cpp
+++ b/tests/pke-test-serialization.cpp
@@ -46,6 +46,7 @@ const pk_uuid uuid_n[] = {
// const pk_uuid uuid_34 = FAKE_UUID_GEN(0x22);
void pke_test_serialization_spinup() {
+ // pk_funcinstr_init();
pkeSettings.isSimulationPaused = true;
Physics_Init();
PkeThreads_Init();
@@ -60,9 +61,11 @@ void pke_test_serialization_spinup() {
// FontType *ft = FontType_GetFonts(fti);
// assert(fti > FontTypeIndex{0});
// ft->uuid = uuid_17;
+ // pk_funcinstr_teardown();
};
void pke_test_serialization_teardown() {
+ // pk_funcinstr_init();
// pke_scene_remove(test_scene->scene_handle); // TODO this doesn't work?
test_scene = nullptr;
pke_scene_master_teardown();
@@ -73,8 +76,8 @@ void pke_test_serialization_teardown() {
AM_Teardown();
PkeThreads_Teardown();
Physics_Teardown();
- pk_memory_teardown_all();
bkt = nullptr;
+ // pk_funcinstr_teardown();
};
int pke_test_serialization_999() {
@@ -131,11 +134,12 @@ Scale:5.000000;4.000000;3.000000
:PKFE:)VOGON";
int pke_test_serialization_001() {
+ pk_funcinstr_init();
int64_t err_index = 0, i;
srlztn_serialize_helper *h;
std::stringstream ss;
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_serialize_init(bkt);
glm::vec3 pos = glm::vec3(0,1,2);
@@ -164,10 +168,11 @@ int pke_test_serialization_001() {
pke_serialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
+ pk_funcinstr_teardown();
return 0;
}
@@ -176,7 +181,7 @@ int pke_test_deserialization_101() {
srlztn_deserialize_helper *h;
std::stringstream ss(test_001_str);
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_deserialize_init(bkt);
pke_deserialize_scene_from_stream(ss, h);
@@ -206,10 +211,10 @@ int pke_test_deserialization_101() {
pke_deserialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
return 0;
}
@@ -247,7 +252,7 @@ int pke_test_serialization_002() {
pke_kve *kve = nullptr;
std::stringstream ss;
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_serialize_init(bkt);
// reminder that 'targeting' moves and rotates the camera, so we shouldn't see these values in the output
@@ -305,10 +310,10 @@ int pke_test_serialization_002() {
pke_serialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
return 0;
}
@@ -319,7 +324,7 @@ int pke_test_deserialization_102() {
srlztn_deserialize_helper *h;
std::stringstream ss(test_002_str);
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_deserialize_init(bkt);
h->scene = test_scene;
@@ -378,10 +383,10 @@ int pke_test_deserialization_102() {
pke_deserialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
return 0;
}
@@ -424,7 +429,7 @@ int pke_test_serialization_003() {
pke_kve *kve = nullptr;
std::stringstream ss;
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_serialize_init(bkt);
FontTypeIndex fti;
@@ -482,10 +487,10 @@ int pke_test_serialization_003() {
pke_serialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
return 0;
}
@@ -496,7 +501,7 @@ int pke_test_deserialization_103() {
srlztn_deserialize_helper *h;
std::stringstream ss(test_003_str);
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_deserialize_init(bkt);
h->scene = test_scene;
@@ -560,10 +565,10 @@ int pke_test_deserialization_103() {
pke_deserialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
return 0;
}
@@ -596,7 +601,7 @@ int pke_test_serialization_004() {
pke_kve *kve = nullptr;
std::stringstream ss;
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_serialize_init(bkt);
pke_ui_box *ui_box_p = pke_ui_box_new_root(PKE_UI_BOX_TYPE_STANDARD, uuid_n[2]);
@@ -644,10 +649,10 @@ int pke_test_serialization_004() {
pke_serialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
return 0;
}
@@ -658,7 +663,7 @@ int pke_test_deserialization_104() {
pke_kve *kve = nullptr;
std::stringstream ss(test_004_str);
try {
- bkt = pk_bucket_create("pke_test_serialization", PK_DEFAULT_BUCKET_SIZE, false);
+ bkt = pk_mem_bucket_create("pke_test_serialization", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
h = pke_deserialize_init(bkt);
pke_deserialize_scene_from_stream(ss, h);
@@ -720,10 +725,10 @@ int pke_test_deserialization_104() {
pke_deserialize_teardown(h);
} catch (const std::exception &ex) {
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
throw;
}
- pk_bucket_destroy(bkt);
+ pk_mem_bucket_destroy(bkt);
return 0;
}
diff --git a/tests/pke-test.cpp b/tests/pke-test.cpp
index 3f6b43b..473327e 100644
--- a/tests/pke-test.cpp
+++ b/tests/pke-test.cpp
@@ -6,7 +6,6 @@
#include "./pke-test-serialization.h"
#include "./pke-test-static-ui.h"
-#include "entities.hpp"
#include "pk.h"
#include "unistd.h"
#include <stdio.h>
@@ -36,12 +35,6 @@ int main(int argc, char *argv[])
double group_ms;
pk_tmr func_tmr;
- // global garbage data when dtor called on program exit
- {
- EntityType_Init();
- EntityType_Teardown();
- }
-
pke_test_get_group *group_fns[] = {
pke_test_dummy_get_group,
pke_test_static_ui_get_group,
@@ -59,6 +52,8 @@ int main(int argc, char *argv[])
fprintf(stdout, "[pke-test]:[%s] Begin.\n", group->title);
if (group->group_setup != NULL) (group->group_setup)();
for (k = 0; k < group->n_tests; ++k) {
+ struct pk_membucket *bkt = pk_mem_bucket_create("pke-test-bucket", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
+ pk_mem_bucket_set_client_mem_bucket(bkt);
fprintf(stdout, "[pke-test]:[%s]:[%s] Begin.\n", group->title, group->tests[k].title);
if (group->test_setup != NULL) (group->test_setup)();
lj.expected_exit = 0;
@@ -76,6 +71,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "[pke-test]:[%s]:[%s] %sFailed.%s Expected: '%i' Got: '%i'.\n", group->title, group->tests[k].title, CLR_RED, CLR_WHITE, group->tests[k].expected_result, result);
}
if (group->test_teardown != NULL) (group->test_teardown)();
+ pk_mem_bucket_destroy(bkt);
}
if (group->group_teardown != NULL) (group->group_teardown)();
fprintf(stdout, "[pke-test]:[%s] End. ( %s%03d%s / %03d ) Tests Completed.\n", group->title, pass_count == group->n_tests ? CLR_GREEN : CLR_RED, pass_count, CLR_WHITE, group->n_tests);