This commit is contained in:
2026-07-19 22:12:53 -05:00
parent e80d693d85
commit 373f1c1010
24 changed files with 1646 additions and 16 deletions
+27
View File
@@ -71,6 +71,32 @@ static void test_entityAddGetDisposeComponent(void **state) {
assert_int_equal(memoryGetAllocatedCount(), 0);
}
static void test_entitySetGetFindByName(void **state) {
entitymanager_t mgr;
entityManagerInit(&mgr);
entityid_t a = entityManagerAdd(&mgr);
entityid_t b = entityManagerAdd(&mgr);
assert_string_equal(entityGetName(&mgr, a), "");
assert_int_equal(entityFindByName(&mgr, "camera"), ENTITY_ID_INVALID);
entitySetName(&mgr, a, "camera");
assert_string_equal(entityGetName(&mgr, a), "camera");
assert_int_equal(entityFindByName(&mgr, "camera"), a);
assert_int_equal(entityFindByName(&mgr, "nonexistent"), ENTITY_ID_INVALID);
// Renaming doesn't leave the old name findable, and other entities stay
// unaffected.
entitySetName(&mgr, a, "player");
assert_int_equal(entityFindByName(&mgr, "camera"), ENTITY_ID_INVALID);
assert_int_equal(entityFindByName(&mgr, "player"), a);
assert_string_equal(entityGetName(&mgr, b), "");
entityManagerDispose(&mgr);
assert_int_equal(memoryGetAllocatedCount(), 0);
}
static void test_entityAddDuplicateComponentAsserts(void **state) {
entitymanager_t mgr;
entityManagerInit(&mgr);
@@ -90,6 +116,7 @@ int main(int argc, char **argv) {
cmocka_unit_test(test_entityManagerAddIsolatesEntities),
cmocka_unit_test(test_entityManagerFullAsserts),
cmocka_unit_test(test_entityAddGetDisposeComponent),
cmocka_unit_test(test_entitySetGetFindByName),
cmocka_unit_test(test_entityAddDuplicateComponentAsserts),
};