From 4636d3f29e8fb2d97a3a984987ac6c86585f4e94 Mon Sep 17 00:00:00 2001 From: Mathew Benson Date: Wed, 30 Sep 2026 19:09:31 +0300 Subject: [PATCH] refactor(tests): Add variables to deal with nodiscard warnings - The variables are unused but existing to comply with the [[nodiscard]] attribute - Convention is to use and underscore, add a relevant name where there is more than one --- ZEngine/tests/ECS/SchedulerTest.cpp | 22 +++++++++++----------- ZEngine/tests/Input/InputManager_test.cpp | 4 ++-- ZEngine/tests/VFS/vfs_meta_test.cpp | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ZEngine/tests/ECS/SchedulerTest.cpp b/ZEngine/tests/ECS/SchedulerTest.cpp index af81313a7..ac8ba1c82 100644 --- a/ZEngine/tests/ECS/SchedulerTest.cpp +++ b/ZEngine/tests/ECS/SchedulerTest.cpp @@ -54,11 +54,11 @@ class SchedulerFixture : public ::testing::Test TEST_F(SchedulerFixture, IndependentSystemsInSameWave) { // A writes Transform, B writes Velocity — no overlap → same wave - auto SystemA = [](Scene&, float, WorldCommands&) {}; - auto SystemB = [](Scene&, float, WorldCommands&) {}; + auto SystemA = [](Scene&, float, WorldCommands&) {}; + auto SystemB = [](Scene&, float, WorldCommands&) {}; - m_tick.RegisterSystem(SystemA, {.WriteMask = MaskBit(ComponentTypeOf())}); - m_tick.RegisterSystem(SystemB, {.WriteMask = MaskBit(ComponentTypeOf())}); + const auto _A = m_tick.RegisterSystem(SystemA, {.WriteMask = MaskBit(ComponentTypeOf())}); + const auto _B = m_tick.RegisterSystem(SystemB, {.WriteMask = MaskBit(ComponentTypeOf())}); m_tick.Commit(); EXPECT_EQ(m_tick.WaveCount(), 1u); @@ -113,11 +113,11 @@ TEST_F(SchedulerFixture, WriteBeforeReadOrderVerifiedViaState) TEST_F(SchedulerFixture, WorldCommandsSpawnAppliedAfterTick) { static EntityID s_spawned; - s_spawned = INVALID_ENTITY; + s_spawned = INVALID_ENTITY; - auto Spawner = [](Scene&, float, WorldCommands& cmds) { cmds.SpawnEntity({&s_spawned, [](void* ctx, EntityID id) { *static_cast(ctx) = id; }}); }; + auto Spawner = [](Scene&, float, WorldCommands& cmds) { cmds.SpawnEntity({&s_spawned, [](void* ctx, EntityID id) { *static_cast(ctx) = id; }}); }; - m_tick.RegisterSystem(Spawner, {}); + const auto _ = m_tick.RegisterSystem(Spawner, {}); m_tick.Commit(); m_tick.Tick(m_scene, 0.016f, m_commands); @@ -168,8 +168,8 @@ TEST_F(SchedulerFixture, ParallelSystemsBothSpawn_BothEntitiesCreated) auto SpawnerB = [](Scene&, float, WorldCommands& cmds) { cmds.SpawnEntity({nullptr, [](void*, EntityID) { s_spawn_count.fetch_add(1, std::memory_order_relaxed); }}); }; // Disjoint masks → same wave (no conflict, no OrderBefore required). - m_tick.RegisterSystem(SpawnerA, {.UsesCommands = true}); - m_tick.RegisterSystem(SpawnerB, {.UsesCommands = true}); + const auto _A = m_tick.RegisterSystem(SpawnerA, {.UsesCommands = true}); + const auto _B = m_tick.RegisterSystem(SpawnerB, {.UsesCommands = true}); m_tick.Commit(); EXPECT_EQ(m_tick.WaveCount(), 1u); @@ -193,8 +193,8 @@ TEST_F(SchedulerFixture, ParallelSpawnCallbacks_IndicesRemappedCorrectly) auto SpawnerA = [](Scene&, float, WorldCommands& cmds) { cmds.SpawnEntity({&s_from_a, [](void* ctx, EntityID id) { *static_cast(ctx) = id; }}); }; auto SpawnerB = [](Scene&, float, WorldCommands& cmds) { cmds.SpawnEntity({&s_from_b, [](void* ctx, EntityID id) { *static_cast(ctx) = id; }}); }; - m_tick.RegisterSystem(SpawnerA, {.UsesCommands = true}); - m_tick.RegisterSystem(SpawnerB, {.UsesCommands = true}); + const auto _A = m_tick.RegisterSystem(SpawnerA, {.UsesCommands = true}); + const auto _B = m_tick.RegisterSystem(SpawnerB, {.UsesCommands = true}); m_tick.Commit(); s_from_a = INVALID_ENTITY; diff --git a/ZEngine/tests/Input/InputManager_test.cpp b/ZEngine/tests/Input/InputManager_test.cpp index f9fd5f549..0fe93ab10 100644 --- a/ZEngine/tests/Input/InputManager_test.cpp +++ b/ZEngine/tests/Input/InputManager_test.cpp @@ -186,8 +186,8 @@ TEST_F(InputManagerTest, GetCurrentFrame_InitialActionCountIsZero) TEST_F(InputManagerTest, GetCurrentFrame_AfterRegistration_ActionCountUpdatedOnNextPoll) { - input.RegisterAction("A", InputActionType::Button); - input.RegisterAction("B", InputActionType::Axis1D); + const auto _A = input.RegisterAction("A", InputActionType::Button); + const auto _B = input.RegisterAction("B", InputActionType::Axis1D); // ActionCount in the frame is set by Poll; before Poll it reflects the // previous Poll's count (0 since Poll hasn't run). EXPECT_EQ(input.GetCurrentFrame().ActionCount, 0u); diff --git a/ZEngine/tests/VFS/vfs_meta_test.cpp b/ZEngine/tests/VFS/vfs_meta_test.cpp index a3db3f1c8..d3cb224de 100644 --- a/ZEngine/tests/VFS/vfs_meta_test.cpp +++ b/ZEngine/tests/VFS/vfs_meta_test.cpp @@ -30,7 +30,7 @@ class MetaFileIOTest : public ::testing::Test m_manager.Initialize(ZMega(16), {}); m_backend.Initialize(&m_manager.MainArena); m_ctx.Initialize(&m_manager.MainArena, 4); - m_ctx.Mount(&m_backend, VFSPath::Root(), 0); + const auto _ = m_ctx.Mount(&m_backend, VFSPath::Root(), 0); } void TearDown() override @@ -50,7 +50,7 @@ class MetaFileIOTest : public ::testing::Test void WriteRaw(const char* path, const char* content) { - m_backend.WriteFile(P(path), Bytes(content, std::strlen(content))); + const auto _ = m_backend.WriteFile(P(path), Bytes(content, std::strlen(content))); } bool FileExists(const char* path)