serialization fixing world unit test and missing serialize for inert.

This commit is contained in:
2026-09-13 11:59:10 -04:00
parent 58b79fb499
commit 2bd0cf39f1
4 changed files with 35 additions and 20 deletions
+23 -4
View File
@@ -11,6 +11,7 @@
#include <Core/Thread/ThreadContext.h>
#include <Data/World.h>
#include <Entity/entity_types.h>
#include <game.h>
namespace UnitTest
{
@@ -20,7 +21,9 @@ namespace UnitTest
TempArena tempArena = scratch_begin(nullptr, 0);
World testWorld{};
GameState* gameState = GetGameState();
World testWorld{};
gameState->World = &testWorld;
InitWorld(&testWorld, tempArena.Arena);
InitEntityManager(&testWorld);
@@ -53,7 +56,10 @@ namespace UnitTest
ShutdownEntityManager();
ShutdownWorld(&testWorld);
gameState->World = nullptr;
scratch_end(tempArena);
Log(LogLevel::Message, LogCategory::Game, "[UnitTest] PASSED: TestEntityAllocationAndWiring");
}
@@ -61,12 +67,16 @@ namespace UnitTest
{
Log(LogLevel::Message, LogCategory::Game, "[UnitTest] Running TestInPlaceDeserialization...");
TempArena tempArena = scratch_begin(nullptr, 0);
World testWorld{};
GameState* gameState = GetGameState();
World testWorld{};
gameState->World = &testWorld;
InitWorld(&testWorld, tempArena.Arena);
InitEntityManager(&testWorld);
EntityManager& manager = *testWorld.EntityManager;
// 1. In-memory .jasset text fixture (no streams or files needed)
String asset_content = ConstString("; class\n"
String asset_content = ConstString("; Class\n"
"Inert\n"
"; version\n"
"1\n"
@@ -100,6 +110,9 @@ namespace UnitTest
Assert(loaded_inert->MeshInstance == 42);
ShutdownEntityManager();
ShutdownWorld(&testWorld);
gameState->World = nullptr;
scratch_end(tempArena);
Log(LogLevel::Message, LogCategory::Game, "[UnitTest] PASSED: TestInPlaceDeserialization");
}
@@ -110,14 +123,18 @@ namespace UnitTest
TempArena tempArena = scratch_begin(nullptr, 0);
World testWorld{};
GameState* gameState = GetGameState();
World testWorld{};
gameState->World = &testWorld;
InitWorld(&testWorld, tempArena.Arena);
InitEntityManager(&testWorld);
EntityManager& manager = *testWorld.EntityManager;
Entity* entity = allocate_entity(manager, Inert::kind);
Assert(entity->is_dirty == true);
// TODO : proper save and mutation
// Simulate save
entity->is_dirty = false;
Assert(entity->is_dirty == false);
@@ -130,6 +147,8 @@ namespace UnitTest
ShutdownEntityManager();
ShutdownWorld(&testWorld);
gameState->World = nullptr;
scratch_end(tempArena);
Log(LogLevel::Message, LogCategory::Game, "[UnitTest] PASSED: TestDirtyTrackingLifecycle");
}