From c9195f997f3e797f03ab90464e4158717198a167 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 07:40:29 +0100 Subject: style: Apply clang-format to all source files --- src/tests/test_demo_effects.cc | 108 +++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'src/tests/test_demo_effects.cc') diff --git a/src/tests/test_demo_effects.cc b/src/tests/test_demo_effects.cc index ec1d68c..3c40bc5 100644 --- a/src/tests/test_demo_effects.cc +++ b/src/tests/test_demo_effects.cc @@ -1,23 +1,31 @@ // This file is part of the 64k demo project. // It tests all demo effect classes for basic construction and initialization. -// Validates that every effect can be instantiated and initialized without crashes. +// Validates that every effect can be instantiated and initialized without +// crashes. // // MAINTENANCE REQUIREMENT: When adding a new effect to demo_effects.h: -// 1. Add it to the appropriate test list (post_process_effects or scene_effects) +// 1. Add it to the appropriate test list (post_process_effects or +// scene_effects) // 2. Update EXPECTED_POST_PROCESS_COUNT or EXPECTED_SCENE_COUNT below // 3. Run test to verify: ./build/test_demo_effects -// 4. If the effect requires Renderer3D, add it to requires_3d check in test_scene_effects() +// 4. If the effect requires Renderer3D, add it to requires_3d check in +// test_scene_effects() -#if !defined(STRIP_ALL) // Test code only - zero size impact on final binary +#if !defined(STRIP_ALL) // Test code only - zero size impact on final binary // Expected effect counts - UPDATE THESE when adding new effects! -static constexpr int EXPECTED_POST_PROCESS_COUNT = 8; // FlashEffect, PassthroughEffect, GaussianBlurEffect, ChromaAberrationEffect, DistortEffect, SolarizeEffect, FadeEffect, ThemeModulationEffect -static constexpr int EXPECTED_SCENE_COUNT = 6; // HeptagonEffect, ParticlesEffect, ParticleSprayEffect, MovingEllipseEffect, FlashCubeEffect, Hybrid3DEffect +static constexpr int EXPECTED_POST_PROCESS_COUNT = + 8; // FlashEffect, PassthroughEffect, GaussianBlurEffect, + // ChromaAberrationEffect, DistortEffect, SolarizeEffect, FadeEffect, + // ThemeModulationEffect +static constexpr int EXPECTED_SCENE_COUNT = + 6; // HeptagonEffect, ParticlesEffect, ParticleSprayEffect, + // MovingEllipseEffect, FlashCubeEffect, Hybrid3DEffect #include "effect_test_helpers.h" -#include "webgpu_test_fixture.h" #include "gpu/demo_effects.h" #include "gpu/effect.h" +#include "webgpu_test_fixture.h" #include #include #include @@ -26,10 +34,8 @@ static constexpr int EXPECTED_SCENE_COUNT = 6; // HeptagonEffect, ParticlesEffe // Helper: Test effect construction and initialization // Returns: 0=failed, 1=passed, 2=skipped (requires full 3D setup) -static int test_effect_smoke(const char* name, - std::shared_ptr effect, - MainSequence* main_seq, - bool requires_3d = false) { +static int test_effect_smoke(const char* name, std::shared_ptr effect, + MainSequence* main_seq, bool requires_3d = false) { fprintf(stdout, " Testing %s...\n", name); // Check construction @@ -53,7 +59,7 @@ static int test_effect_smoke(const char* name, // These will fail in init_test() environment - skip them gracefully if (requires_3d) { fprintf(stdout, " ⚠ Skipped (requires full 3D pipeline setup)\n"); - return 2; // Skipped + return 2; // Skipped } seq->init(main_seq); @@ -65,7 +71,7 @@ static int test_effect_smoke(const char* name, } fprintf(stdout, " ✓ %s construction and initialization OK\n", name); - return 1; // Passed + return 1; // Passed } // Test 1: Post-process effects @@ -83,24 +89,17 @@ static void test_post_process_effects() { // Test each post-process effect std::vector>> effects = { - {"FlashEffect", - std::make_shared(fixture.ctx())}, - {"PassthroughEffect", - std::make_shared(fixture.ctx())}, + {"FlashEffect", std::make_shared(fixture.ctx())}, + {"PassthroughEffect", std::make_shared(fixture.ctx())}, {"GaussianBlurEffect", std::make_shared(fixture.ctx())}, {"ChromaAberrationEffect", - std::make_shared( - fixture.ctx())}, - {"DistortEffect", - std::make_shared(fixture.ctx())}, - {"SolarizeEffect", - std::make_shared(fixture.ctx())}, - {"FadeEffect", - std::make_shared(fixture.ctx())}, + std::make_shared(fixture.ctx())}, + {"DistortEffect", std::make_shared(fixture.ctx())}, + {"SolarizeEffect", std::make_shared(fixture.ctx())}, + {"FadeEffect", std::make_shared(fixture.ctx())}, {"ThemeModulationEffect", - std::make_shared( - fixture.ctx())}, + std::make_shared(fixture.ctx())}, }; int passed = 0; @@ -121,10 +120,15 @@ static void test_post_process_effects() { // Validation: Ensure test coverage matches expected count const int tested_count = static_cast(effects.size()); if (tested_count != EXPECTED_POST_PROCESS_COUNT) { - fprintf(stderr, " ✗ COVERAGE ERROR: Expected %d post-process effects, but only tested %d!\n", + fprintf(stderr, + " ✗ COVERAGE ERROR: Expected %d post-process effects, but only " + "tested %d!\n", EXPECTED_POST_PROCESS_COUNT, tested_count); - fprintf(stderr, " ✗ Did you add a new post-process effect without updating the test?\n"); - fprintf(stderr, " ✗ Update EXPECTED_POST_PROCESS_COUNT in test_demo_effects.cc\n"); + fprintf(stderr, + " ✗ Did you add a new post-process effect without updating the " + "test?\n"); + fprintf(stderr, + " ✗ Update EXPECTED_POST_PROCESS_COUNT in test_demo_effects.cc\n"); assert(false && "Post-process effect count mismatch - update test!"); } } @@ -144,18 +148,14 @@ static void test_scene_effects() { // Test each scene effect std::vector>> effects = { - {"HeptagonEffect", - std::make_shared(fixture.ctx())}, - {"ParticlesEffect", - std::make_shared(fixture.ctx())}, + {"HeptagonEffect", std::make_shared(fixture.ctx())}, + {"ParticlesEffect", std::make_shared(fixture.ctx())}, {"ParticleSprayEffect", std::make_shared(fixture.ctx())}, {"MovingEllipseEffect", std::make_shared(fixture.ctx())}, - {"FlashCubeEffect", - std::make_shared(fixture.ctx())}, - {"Hybrid3DEffect", - std::make_shared(fixture.ctx())}, + {"FlashCubeEffect", std::make_shared(fixture.ctx())}, + {"Hybrid3DEffect", std::make_shared(fixture.ctx())}, }; int passed = 0; @@ -183,10 +183,14 @@ static void test_scene_effects() { // Validation: Ensure test coverage matches expected count const int tested_count = static_cast(effects.size()); if (tested_count != EXPECTED_SCENE_COUNT) { - fprintf(stderr, " ✗ COVERAGE ERROR: Expected %d scene effects, but only tested %d!\n", - EXPECTED_SCENE_COUNT, tested_count); - fprintf(stderr, " ✗ Did you add a new scene effect without updating the test?\n"); - fprintf(stderr, " ✗ Update EXPECTED_SCENE_COUNT in test_demo_effects.cc\n"); + fprintf( + stderr, + " ✗ COVERAGE ERROR: Expected %d scene effects, but only tested %d!\n", + EXPECTED_SCENE_COUNT, tested_count); + fprintf(stderr, + " ✗ Did you add a new scene effect without updating the test?\n"); + fprintf(stderr, + " ✗ Update EXPECTED_SCENE_COUNT in test_demo_effects.cc\n"); assert(false && "Scene effect count mismatch - update test!"); } } @@ -202,21 +206,19 @@ static void test_effect_type_classification() { } // Post-process effects should return true - auto flash = std::make_shared( - fixture.ctx()); + auto flash = std::make_shared(fixture.ctx()); assert(flash->is_post_process() && "FlashEffect should be post-process"); - auto blur = std::make_shared( - fixture.ctx()); - assert(blur->is_post_process() && "GaussianBlurEffect should be post-process"); + auto blur = std::make_shared(fixture.ctx()); + assert(blur->is_post_process() && + "GaussianBlurEffect should be post-process"); // Scene effects should return false - auto heptagon = std::make_shared( - fixture.ctx()); - assert(!heptagon->is_post_process() && "HeptagonEffect should NOT be post-process"); + auto heptagon = std::make_shared(fixture.ctx()); + assert(!heptagon->is_post_process() && + "HeptagonEffect should NOT be post-process"); - auto particles = std::make_shared( - fixture.ctx()); + auto particles = std::make_shared(fixture.ctx()); assert(!particles->is_post_process() && "ParticlesEffect should NOT be post-process"); @@ -234,4 +236,4 @@ int main() { return 0; } -#endif /* !defined(STRIP_ALL) */ +#endif /* !defined(STRIP_ALL) */ -- cgit v1.2.3