From 8ce27b7e15f0fc65c8ee78950c7501660b936178 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 14 Feb 2026 15:14:25 +0100 Subject: style: Apply clang-format to codebase --- src/tests/3d/test_3d.cc | 11 ++++++---- src/tests/3d/test_3d_physics.cc | 2 +- src/tests/3d/test_3d_render.cc | 2 +- src/tests/3d/test_mesh.cc | 2 +- src/tests/3d/test_physics.cc | 12 +++++++---- src/tests/audio/test_audio_engine.cc | 2 +- src/tests/audio/test_silent_backend.cc | 2 +- src/tests/audio/test_tracker.cc | 2 +- src/tests/audio/test_tracker_timing.cc | 5 ++--- src/tests/audio/test_variable_tempo.cc | 11 +++++----- src/tests/audio/test_wav_dump.cc | 2 +- src/tests/common/audio_test_fixture.cc | 5 ++--- src/tests/common/audio_test_fixture.h | 14 ++++++------- src/tests/common/effect_test_fixture.cc | 3 ++- src/tests/common/effect_test_fixture.h | 18 ++++++++++------ src/tests/common/offscreen_render_target.cc | 2 +- src/tests/common/test_math_helpers.h | 5 ++--- src/tests/gpu/test_demo_effects.cc | 4 ++-- src/tests/gpu/test_effect_base.cc | 4 ++-- src/tests/gpu/test_gpu_composite.cc | 18 ++++++++-------- src/tests/gpu/test_post_process_helper.cc | 27 ++++++++++++------------ src/tests/gpu/test_shader_assets.cc | 22 +++++++++++--------- src/tests/gpu/test_texture_manager.cc | 2 +- src/tests/util/test_maths.cc | 32 ++++++++++++++++++----------- 24 files changed, 116 insertions(+), 93 deletions(-) (limited to 'src/tests') diff --git a/src/tests/3d/test_3d.cc b/src/tests/3d/test_3d.cc index 7132b33..13edd45 100644 --- a/src/tests/3d/test_3d.cc +++ b/src/tests/3d/test_3d.cc @@ -1,10 +1,10 @@ // This file is part of the 64k demo project. // It tests the 3D system components (Camera, Object, Scene). +#include "../common/test_math_helpers.h" #include "3d/camera.h" #include "3d/object.h" #include "3d/scene.h" -#include "../common/test_math_helpers.h" #include #include @@ -76,7 +76,8 @@ void test_object_transform() { vec4 original_space_t = inv_model_t * vec4(translated_point.x, translated_point.y, translated_point.z, 1.0); - assert(test_near(original_space_t.x, 0.0f, 0.001f) && test_near(original_space_t.y, 0.0f, 0.001f) && + assert(test_near(original_space_t.x, 0.0f, 0.001f) && + test_near(original_space_t.y, 0.0f, 0.001f) && test_near(original_space_t.z, 0.0f, 0.001f)); // Model matrix with rotation (90 deg Y) and translation (5,0,0) @@ -88,10 +89,12 @@ void test_object_transform() { // Translates to (5,0,-1) vec4 p_trs(1, 0, 0, 1); vec4 transformed_p = model_trs * p_trs; - assert(test_near(transformed_p.x, 5.0f, 0.001f) && test_near(transformed_p.z, -1.0f, 0.001f)); + assert(test_near(transformed_p.x, 5.0f, 0.001f) && + test_near(transformed_p.z, -1.0f, 0.001f)); // Apply inverse to transformed point to get back original point vec4 original_space_trs = inv_model_trs * transformed_p; - assert(test_near(original_space_trs.x, 1.0f, 0.001f) && test_near(original_space_trs.y, 0.0f, 0.001f) && + assert(test_near(original_space_trs.x, 1.0f, 0.001f) && + test_near(original_space_trs.y, 0.0f, 0.001f) && test_near(original_space_trs.z, 0.0f, 0.001f)); } diff --git a/src/tests/3d/test_3d_physics.cc b/src/tests/3d/test_3d_physics.cc index 9e4f71b..26b9bfa 100644 --- a/src/tests/3d/test_3d_physics.cc +++ b/src/tests/3d/test_3d_physics.cc @@ -1,6 +1,7 @@ // This file is part of the 64k demo project. // Standalone "mini-demo" for testing the 3D physics engine. +#include "../common/test_3d_helpers.h" #include "3d/bvh.h" #include "3d/camera.h" #include "3d/object.h" @@ -12,7 +13,6 @@ #include "gpu/texture_manager.h" #include "platform/platform.h" #include "procedural/generator.h" -#include "../common/test_3d_helpers.h" #include #include #include diff --git a/src/tests/3d/test_3d_render.cc b/src/tests/3d/test_3d_render.cc index 10de907..9398649 100644 --- a/src/tests/3d/test_3d_render.cc +++ b/src/tests/3d/test_3d_render.cc @@ -1,6 +1,7 @@ // This file is part of the 64k demo project. // Standalone "mini-demo" for testing the 3D renderer. +#include "../common/test_3d_helpers.h" #include "3d/camera.h" #include "3d/object.h" #include "3d/renderer.h" @@ -11,7 +12,6 @@ #include "gpu/texture_manager.h" #include "platform/platform.h" #include "procedural/generator.h" -#include "../common/test_3d_helpers.h" #include #include #include diff --git a/src/tests/3d/test_mesh.cc b/src/tests/3d/test_mesh.cc index d4ce097..2a13125 100644 --- a/src/tests/3d/test_mesh.cc +++ b/src/tests/3d/test_mesh.cc @@ -1,6 +1,7 @@ // This file is part of the 64k demo project. // Standalone test for loading and rendering a single mesh from a .obj file. +#include "../common/test_3d_helpers.h" #include "3d/camera.h" #include "3d/object.h" #include "3d/renderer.h" @@ -11,7 +12,6 @@ #include "platform/platform.h" #include "procedural/generator.h" #include "util/asset_manager_utils.h" -#include "../common/test_3d_helpers.h" #include #include #include diff --git a/src/tests/3d/test_physics.cc b/src/tests/3d/test_physics.cc index c1c5c32..6c1f814 100644 --- a/src/tests/3d/test_physics.cc +++ b/src/tests/3d/test_physics.cc @@ -1,10 +1,10 @@ // This file is part of the 64k demo project. // It tests the CPU-side SDF library and BVH for physics and collision. +#include "../common/test_math_helpers.h" #include "3d/bvh.h" #include "3d/physics.h" #include "3d/sdf_cpu.h" -#include "../common/test_math_helpers.h" #include #include @@ -46,18 +46,22 @@ void test_calc_normal() { // Sphere normal at (1,0,0) should be (1,0,0) auto sphere_sdf = [](vec3 p) { return sdf::sdSphere(p, 1.0f); }; vec3 n = sdf::calc_normal({1, 0, 0}, sphere_sdf); - assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && test_near(n.z, 0.0f, 0.001f)); + assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && + test_near(n.z, 0.0f, 0.001f)); // Box normal at side auto box_sdf = [](vec3 p) { return sdf::sdBox(p, {1, 1, 1}); }; n = sdf::calc_normal({1, 0, 0}, box_sdf); - assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && test_near(n.z, 0.0f, 0.001f)); + assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && + test_near(n.z, 0.0f, 0.001f)); // Plane normal should be n vec3 plane_n(0, 1, 0); auto plane_sdf = [plane_n](vec3 p) { return sdf::sdPlane(p, plane_n, 1.0f); }; n = sdf::calc_normal({0, 0, 0}, plane_sdf); - assert(test_near(n.x, plane_n.x, 0.001f) && test_near(n.y, plane_n.y, 0.001f) && test_near(n.z, plane_n.z, 0.001f)); + assert(test_near(n.x, plane_n.x, 0.001f) && + test_near(n.y, plane_n.y, 0.001f) && + test_near(n.z, plane_n.z, 0.001f)); } void test_bvh() { diff --git a/src/tests/audio/test_audio_engine.cc b/src/tests/audio/test_audio_engine.cc index 72c1653..3f0ad4d 100644 --- a/src/tests/audio/test_audio_engine.cc +++ b/src/tests/audio/test_audio_engine.cc @@ -1,10 +1,10 @@ // This file is part of the 64k demo project. // Unit tests for AudioEngine lifecycle and resource management. +#include "../common/audio_test_fixture.h" #include "audio/audio_engine.h" #include "audio/tracker.h" #include "generated/assets.h" -#include "../common/audio_test_fixture.h" #include #include diff --git a/src/tests/audio/test_silent_backend.cc b/src/tests/audio/test_silent_backend.cc index cc98139..3dc1cd4 100644 --- a/src/tests/audio/test_silent_backend.cc +++ b/src/tests/audio/test_silent_backend.cc @@ -2,11 +2,11 @@ // It tests the SilentBackend for audio testing without hardware. // Verifies audio.cc functionality using silent backend. +#include "../common/audio_test_fixture.h" #include "audio/audio.h" #include "audio/audio_engine.h" #include "audio/backend/silent_backend.h" #include "audio/synth.h" -#include "../common/audio_test_fixture.h" #include #include diff --git a/src/tests/audio/test_tracker.cc b/src/tests/audio/test_tracker.cc index 1112e91..ab2505d 100644 --- a/src/tests/audio/test_tracker.cc +++ b/src/tests/audio/test_tracker.cc @@ -1,11 +1,11 @@ // This file is part of the 64k demo project. // It tests the core functionality of the audio tracker engine. +#include "../common/audio_test_fixture.h" #include "audio/audio_engine.h" #include "audio/gen.h" #include "audio/synth.h" #include "audio/tracker.h" -#include "../common/audio_test_fixture.h" // #include "generated/music_data.h" // Will be generated by tracker_compiler #include #include diff --git a/src/tests/audio/test_tracker_timing.cc b/src/tests/audio/test_tracker_timing.cc index 7295de3..1c2d6fd 100644 --- a/src/tests/audio/test_tracker_timing.cc +++ b/src/tests/audio/test_tracker_timing.cc @@ -2,12 +2,12 @@ // It tests tracker timing and synchronization using MockAudioBackend. // Verifies pattern triggers occur at correct times with proper BPM scaling. +#include "../common/audio_test_fixture.h" #include "audio/audio.h" #include "audio/audio_engine.h" #include "audio/backend/mock_audio_backend.h" #include "audio/synth.h" #include "audio/tracker.h" -#include "../common/audio_test_fixture.h" #include #include #include @@ -15,8 +15,7 @@ #if !defined(STRIP_ALL) // Helper: Setup audio engine for testing -static AudioTestFixture* -setup_audio_test(MockAudioBackend& backend) { +static AudioTestFixture* setup_audio_test(MockAudioBackend& backend) { audio_set_backend(&backend); return new AudioTestFixture(); } diff --git a/src/tests/audio/test_variable_tempo.cc b/src/tests/audio/test_variable_tempo.cc index da056c5..9c9a471 100644 --- a/src/tests/audio/test_variable_tempo.cc +++ b/src/tests/audio/test_variable_tempo.cc @@ -2,11 +2,11 @@ // It tests variable tempo system with music_time scaling. // Verifies 2x speed-up and 2x slow-down reset tricks. +#include "../common/audio_test_fixture.h" #include "audio/audio.h" #include "audio/audio_engine.h" #include "audio/backend/mock_audio_backend.h" #include "audio/tracker.h" -#include "../common/audio_test_fixture.h" #include #include #include @@ -14,8 +14,7 @@ #if !defined(STRIP_ALL) // Helper: Setup audio engine for testing -static AudioTestFixture* -setup_audio_test(MockAudioBackend& backend) { +static AudioTestFixture* setup_audio_test(MockAudioBackend& backend) { audio_set_backend(&backend); AudioTestFixture* fixture = new AudioTestFixture(); fixture->load_music(&g_tracker_score, g_tracker_samples, @@ -98,7 +97,8 @@ void test_2x_speedup_reset_trick() { // Phase 1: Accelerate from 1.0x to 2.0x over 5 seconds printf(" Phase 1: Accelerating 1.0x → 2.0x\n"); auto accel_fn = [](float t) { return fminf(1.0f + (t / 5.0f), 2.0f); }; - simulate_tempo_fn(fixture->engine(), music_time, physical_time, 5.0f, dt, accel_fn); + simulate_tempo_fn(fixture->engine(), music_time, physical_time, 5.0f, dt, + accel_fn); const float tempo_scale = accel_fn(physical_time); printf(" After 5s physical: tempo=%.2fx, music_time=%.3f\n", tempo_scale, @@ -132,7 +132,8 @@ void test_2x_slowdown_reset_trick() { // Phase 1: Decelerate from 1.0x to 0.5x over 5 seconds printf(" Phase 1: Decelerating 1.0x → 0.5x\n"); auto decel_fn = [](float t) { return fmaxf(1.0f - (t / 10.0f), 0.5f); }; - simulate_tempo_fn(fixture->engine(), music_time, physical_time, 5.0f, dt, decel_fn); + simulate_tempo_fn(fixture->engine(), music_time, physical_time, 5.0f, dt, + decel_fn); const float tempo_scale = decel_fn(physical_time); printf(" After 5s physical: tempo=%.2fx, music_time=%.3f\n", tempo_scale, diff --git a/src/tests/audio/test_wav_dump.cc b/src/tests/audio/test_wav_dump.cc index 9175153..a0f2a4a 100644 --- a/src/tests/audio/test_wav_dump.cc +++ b/src/tests/audio/test_wav_dump.cc @@ -1,11 +1,11 @@ // This file is part of the 64k demo project. // Regression test for WAV dump backend to prevent format mismatches. +#include "../common/audio_test_fixture.h" #include "audio/audio.h" #include "audio/audio_engine.h" #include "audio/backend/wav_dump_backend.h" #include "audio/ring_buffer.h" -#include "../common/audio_test_fixture.h" #include #include #include diff --git a/src/tests/common/audio_test_fixture.cc b/src/tests/common/audio_test_fixture.cc index 42bf27f..13a5234 100644 --- a/src/tests/common/audio_test_fixture.cc +++ b/src/tests/common/audio_test_fixture.cc @@ -12,8 +12,7 @@ AudioTestFixture::~AudioTestFixture() { } void AudioTestFixture::load_music(const TrackerScore* score, - const NoteParams* samples, - const AssetId* assets, - uint32_t count) { + const NoteParams* samples, + const AssetId* assets, uint32_t count) { m_engine.load_music_data(score, samples, assets, count); } diff --git a/src/tests/common/audio_test_fixture.h b/src/tests/common/audio_test_fixture.h index 328e167..fefc37a 100644 --- a/src/tests/common/audio_test_fixture.h +++ b/src/tests/common/audio_test_fixture.h @@ -9,18 +9,18 @@ // RAII wrapper for AudioEngine lifecycle class AudioTestFixture { -public: + public: AudioTestFixture(); // Calls engine.init() ~AudioTestFixture(); // Calls engine.shutdown() - AudioEngine& engine() { return m_engine; } + AudioEngine& engine() { + return m_engine; + } // Helper: Load tracker music data - void load_music(const TrackerScore* score, - const NoteParams* samples, - const AssetId* assets, - uint32_t count); + void load_music(const TrackerScore* score, const NoteParams* samples, + const AssetId* assets, uint32_t count); -private: + private: AudioEngine m_engine; }; diff --git a/src/tests/common/effect_test_fixture.cc b/src/tests/common/effect_test_fixture.cc index b403ef6..70765c3 100644 --- a/src/tests/common/effect_test_fixture.cc +++ b/src/tests/common/effect_test_fixture.cc @@ -4,7 +4,8 @@ #include "effect_test_fixture.h" #include -EffectTestFixture::EffectTestFixture() {} +EffectTestFixture::EffectTestFixture() { +} EffectTestFixture::~EffectTestFixture() { if (m_initialized) { diff --git a/src/tests/common/effect_test_fixture.h b/src/tests/common/effect_test_fixture.h index 399b5ed..3b01370 100644 --- a/src/tests/common/effect_test_fixture.h +++ b/src/tests/common/effect_test_fixture.h @@ -2,13 +2,13 @@ // Simplifies GPU effect test setup #pragma once -#include "webgpu_test_fixture.h" #include "audio_test_fixture.h" #include "gpu/sequence.h" +#include "webgpu_test_fixture.h" // Combined WebGPU + AudioEngine + MainSequence fixture class EffectTestFixture { -public: + public: EffectTestFixture(); ~EffectTestFixture(); @@ -16,11 +16,17 @@ public: bool init(); // Accessors - GpuContext ctx() const { return m_gpu.ctx(); } - MainSequence& sequence() { return m_sequence; } - AudioEngine& audio() { return m_audio.engine(); } + GpuContext ctx() const { + return m_gpu.ctx(); + } + MainSequence& sequence() { + return m_sequence; + } + AudioEngine& audio() { + return m_audio.engine(); + } -private: + private: WebGPUTestFixture m_gpu; AudioTestFixture m_audio; MainSequence m_sequence; diff --git a/src/tests/common/offscreen_render_target.cc b/src/tests/common/offscreen_render_target.cc index d322a7c..da2fa8f 100644 --- a/src/tests/common/offscreen_render_target.cc +++ b/src/tests/common/offscreen_render_target.cc @@ -61,6 +61,6 @@ std::vector OffscreenRenderTarget::read_pixels() { #if !defined(STRIP_ALL) return read_texture_pixels(instance_, device_, texture_, width_, height_); #else - return std::vector(); // Should never be called in STRIP_ALL builds + return std::vector(); // Should never be called in STRIP_ALL builds #endif } diff --git a/src/tests/common/test_math_helpers.h b/src/tests/common/test_math_helpers.h index 99e7f9d..24d0f3a 100644 --- a/src/tests/common/test_math_helpers.h +++ b/src/tests/common/test_math_helpers.h @@ -2,8 +2,8 @@ // Common floating-point comparison helpers #pragma once -#include #include "util/mini_math.h" +#include // Floating-point comparison with epsilon tolerance inline bool test_near(float a, float b, float epsilon = 1e-6f) { @@ -12,7 +12,6 @@ inline bool test_near(float a, float b, float epsilon = 1e-6f) { // Vector comparison inline bool test_near_vec3(vec3 a, vec3 b, float epsilon = 1e-6f) { - return test_near(a.x, b.x, epsilon) && - test_near(a.y, b.y, epsilon) && + return test_near(a.x, b.x, epsilon) && test_near(a.y, b.y, epsilon) && test_near(a.z, b.z, epsilon); } diff --git a/src/tests/gpu/test_demo_effects.cc b/src/tests/gpu/test_demo_effects.cc index 7c61691..4234901 100644 --- a/src/tests/gpu/test_demo_effects.cc +++ b/src/tests/gpu/test_demo_effects.cc @@ -11,10 +11,10 @@ // test_scene_effects() #include "../common/effect_test_helpers.h" +#include "../common/webgpu_test_fixture.h" +#include "effects/cnn_effect.h" #include "gpu/demo_effects.h" #include "gpu/effect.h" -#include "effects/cnn_effect.h" -#include "../common/webgpu_test_fixture.h" #include #include #include diff --git a/src/tests/gpu/test_effect_base.cc b/src/tests/gpu/test_effect_base.cc index 08cf0a1..f049dff 100644 --- a/src/tests/gpu/test_effect_base.cc +++ b/src/tests/gpu/test_effect_base.cc @@ -3,10 +3,10 @@ // Verifies effect initialization, activation, and basic rendering. #include "../common/effect_test_helpers.h" -#include "gpu/demo_effects.h" -#include "gpu/effect.h" #include "../common/offscreen_render_target.h" #include "../common/webgpu_test_fixture.h" +#include "gpu/demo_effects.h" +#include "gpu/effect.h" #include #include #include diff --git a/src/tests/gpu/test_gpu_composite.cc b/src/tests/gpu/test_gpu_composite.cc index e5ac788..28c76df 100644 --- a/src/tests/gpu/test_gpu_composite.cc +++ b/src/tests/gpu/test_gpu_composite.cc @@ -52,9 +52,9 @@ int main() { } blend_uni = {256, 256, 0.5f, 0.0f}; std::vector blend_inputs = {"noise_a", "noise_b"}; - tex_mgr.create_gpu_composite_texture("blended", "gen_blend", - gen_blend_compute_wgsl, &blend_uni, - sizeof(blend_uni), 256, 256, blend_inputs); + tex_mgr.create_gpu_composite_texture( + "blended", "gen_blend", gen_blend_compute_wgsl, &blend_uni, + sizeof(blend_uni), 256, 256, blend_inputs); WGPUTextureView blended_view = tex_mgr.get_texture_view("blended"); if (!blended_view) { @@ -72,9 +72,9 @@ int main() { } mask_uni = {256, 256}; std::vector mask_inputs = {"noise_a", "grid"}; - tex_mgr.create_gpu_composite_texture("masked", "gen_mask", gen_mask_compute_wgsl, - &mask_uni, sizeof(mask_uni), 256, 256, - mask_inputs); + tex_mgr.create_gpu_composite_texture("masked", "gen_mask", + gen_mask_compute_wgsl, &mask_uni, + sizeof(mask_uni), 256, 256, mask_inputs); WGPUTextureView masked_view = tex_mgr.get_texture_view("masked"); if (!masked_view) { @@ -92,9 +92,9 @@ int main() { } blend2_uni = {256, 256, 0.7f, 0.0f}; std::vector blend2_inputs = {"blended", "masked"}; - tex_mgr.create_gpu_composite_texture("final", "gen_blend", - gen_blend_compute_wgsl, &blend2_uni, - sizeof(blend2_uni), 256, 256, blend2_inputs); + tex_mgr.create_gpu_composite_texture( + "final", "gen_blend", gen_blend_compute_wgsl, &blend2_uni, + sizeof(blend2_uni), 256, 256, blend2_inputs); WGPUTextureView final_view = tex_mgr.get_texture_view("final"); if (!final_view) { diff --git a/src/tests/gpu/test_post_process_helper.cc b/src/tests/gpu/test_post_process_helper.cc index 42b5d79..575291d 100644 --- a/src/tests/gpu/test_post_process_helper.cc +++ b/src/tests/gpu/test_post_process_helper.cc @@ -2,10 +2,10 @@ // It tests post-processing helper functions (pipeline and bind group creation). // Validates that helpers can create valid WebGPU resources. -#include "gpu/demo_effects.h" -#include "gpu/gpu.h" #include "../common/offscreen_render_target.h" #include "../common/webgpu_test_fixture.h" +#include "gpu/demo_effects.h" +#include "gpu/gpu.h" #include #include @@ -15,10 +15,11 @@ extern WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, const char* shader_code); extern void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline, WGPUBindGroup* bind_group, - WGPUTextureView input_view, - GpuBuffer uniforms, GpuBuffer effect_params); + WGPUTextureView input_view, GpuBuffer uniforms, + GpuBuffer effect_params); -// Helpers are now in gpu.h (gpu_create_post_process_texture, gpu_create_texture_view_2d) +// Helpers are now in gpu.h (gpu_create_post_process_texture, +// gpu_create_texture_view_2d) // Minimal valid post-process shader for testing static const char* test_shader = R"( @@ -66,8 +67,8 @@ static void test_bind_group_creation(WebGPUTestFixture& fixture) { assert(pipeline != nullptr && "Pipeline required for bind group test"); // Create input texture with TEXTURE_BINDING usage - TextureWithView input = - gpu_create_post_process_texture(fixture.device(), 256, 256, fixture.format()); + TextureWithView input = gpu_create_post_process_texture( + fixture.device(), 256, 256, fixture.format()); // Create uniform buffers using gpu_create_buffer GpuBuffer uniforms = gpu_create_buffer( @@ -103,10 +104,10 @@ static void test_bind_group_update(WebGPUTestFixture& fixture) { WGPURenderPipeline pipeline = create_post_process_pipeline( fixture.device(), fixture.format(), test_shader); - TextureWithView texture1 = - gpu_create_post_process_texture(fixture.device(), 256, 256, fixture.format()); - TextureWithView texture2 = - gpu_create_post_process_texture(fixture.device(), 512, 512, fixture.format()); + TextureWithView texture1 = gpu_create_post_process_texture( + fixture.device(), 256, 256, fixture.format()); + TextureWithView texture2 = gpu_create_post_process_texture( + fixture.device(), 512, 512, fixture.format()); GpuBuffer uniforms = gpu_create_buffer( fixture.device(), 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); @@ -150,8 +151,8 @@ static void test_full_setup(WebGPUTestFixture& fixture) { assert(pipeline != nullptr && "Pipeline creation failed"); // Create input texture (with TEXTURE_BINDING usage) - TextureWithView input = - gpu_create_post_process_texture(fixture.device(), 256, 256, fixture.format()); + TextureWithView input = gpu_create_post_process_texture( + fixture.device(), 256, 256, fixture.format()); // Create output texture (can use OffscreenRenderTarget for this) OffscreenRenderTarget output_target(fixture.instance(), fixture.device(), 256, diff --git a/src/tests/gpu/test_shader_assets.cc b/src/tests/gpu/test_shader_assets.cc index 5619a61..7f2811e 100644 --- a/src/tests/gpu/test_shader_assets.cc +++ b/src/tests/gpu/test_shader_assets.cc @@ -70,16 +70,18 @@ int main() { all_passed &= validate_shader(AssetId::ASSET_SHADER_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", {"@vertex", "vs_main", "@fragment", "fs_main"}); - all_passed &= validate_shader(AssetId::ASSET_SHADER_SOLARIZE, "SOLARIZE", - {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); - all_passed &= validate_shader(AssetId::ASSET_SHADER_DISTORT, "DISTORT", - {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); - all_passed &= validate_shader(AssetId::ASSET_SHADER_CHROMA_ABERRATION, - "CHROMA_ABERRATION", - {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); - all_passed &= validate_shader(AssetId::ASSET_SHADER_VIGNETTE, - "VIGNETTE", - {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); + all_passed &= validate_shader( + AssetId::ASSET_SHADER_SOLARIZE, "SOLARIZE", + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); + all_passed &= validate_shader( + AssetId::ASSET_SHADER_DISTORT, "DISTORT", + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); + all_passed &= validate_shader( + AssetId::ASSET_SHADER_CHROMA_ABERRATION, "CHROMA_ABERRATION", + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); + all_passed &= validate_shader( + AssetId::ASSET_SHADER_VIGNETTE, "VIGNETTE", + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); all_passed &= validate_shader(AssetId::ASSET_SHADER_VISUAL_DEBUG, "VISUAL_DEBUG", {"@vertex", "vs_main", "@fragment", "fs_main"}); diff --git a/src/tests/gpu/test_texture_manager.cc b/src/tests/gpu/test_texture_manager.cc index 54a1a8a..b38e69f 100644 --- a/src/tests/gpu/test_texture_manager.cc +++ b/src/tests/gpu/test_texture_manager.cc @@ -2,9 +2,9 @@ // It tests the TextureManager for procedural texture generation and management. // Tests all public methods with both success and failure cases. +#include "../common/webgpu_test_fixture.h" #include "gpu/texture_manager.h" #include "procedural/generator.h" -#include "../common/webgpu_test_fixture.h" #include #include #include diff --git a/src/tests/util/test_maths.cc b/src/tests/util/test_maths.cc index 4233adc..ceee756 100644 --- a/src/tests/util/test_maths.cc +++ b/src/tests/util/test_maths.cc @@ -2,8 +2,8 @@ // It tests the mathematical utility functions. // Verifies vector operations, matrix transformations, and interpolation. -#include "util/mini_math.h" #include "../common/test_math_helpers.h" +#include "util/mini_math.h" #include #include #include @@ -64,7 +64,8 @@ void test_vec3_special() { // Cross Product vec3 c = vec3::cross(v, v2); - assert(test_near(c.x, 0, 0.001f) && test_near(c.y, 0, 0.001f) && test_near(c.z, 1, 0.001f)); + assert(test_near(c.x, 0, 0.001f) && test_near(c.y, 0, 0.001f) && + test_near(c.z, 1, 0.001f)); } // Tests quaternion rotation, look_at, and slerp @@ -84,11 +85,13 @@ void test_quat() { quat half_pi_rot = quat::from_axis({0, 1, 0}, 3.14159f); // 180 deg Y vec3 rotated_half_pi = half_pi_rot.rotate(v); - assert(test_near(rotated_half_pi.x, -1.0f, 0.001f)); // Rotated 180 deg around Y + assert( + test_near(rotated_half_pi.x, -1.0f, 0.001f)); // Rotated 180 deg around Y vec3 zero_vec(0, 0, 0); vec3 rotated_zero_vec = q.rotate(zero_vec); - assert(test_near(rotated_zero_vec.x, 0.0f, 0.001f) && test_near(rotated_zero_vec.y, 0.0f, 0.001f) && + assert(test_near(rotated_zero_vec.x, 0.0f, 0.001f) && + test_near(rotated_zero_vec.y, 0.0f, 0.001f) && test_near(rotated_zero_vec.z, 0.0f, 0.001f)); // Look At @@ -96,21 +99,26 @@ void test_quat() { // The local forward vector (0,0,-1) should be transformed to (1,0,0) quat l = quat::look_at({0, 0, 0}, {10, 0, 0}, {0, 1, 0}); vec3 f = l.rotate({0, 0, -1}); - assert(test_near(f.x, 1.0f, 0.001f) && test_near(f.y, 0.0f, 0.001f) && test_near(f.z, 0.0f, 0.001f)); + assert(test_near(f.x, 1.0f, 0.001f) && test_near(f.y, 0.0f, 0.001f) && + test_near(f.z, 0.0f, 0.001f)); // Slerp Midpoint quat q1(0, 0, 0, 1); quat q2 = quat::from_axis({0, 1, 0}, 1.5708f); // 90 deg quat mid = slerp(q1, q2, 0.5f); // 45 deg - assert(test_near(mid.y, 0.3826f, 0.001f)); // sin(pi/8) + assert(test_near(mid.y, 0.3826f, 0.001f)); // sin(pi/8) // Slerp edge cases quat slerp_mid_edge = slerp(q1, q2, 0.0f); - assert(test_near(slerp_mid_edge.w, q1.w, 0.001f) && test_near(slerp_mid_edge.x, q1.x, 0.001f) && - test_near(slerp_mid_edge.y, q1.y, 0.001f) && test_near(slerp_mid_edge.z, q1.z, 0.001f)); + assert(test_near(slerp_mid_edge.w, q1.w, 0.001f) && + test_near(slerp_mid_edge.x, q1.x, 0.001f) && + test_near(slerp_mid_edge.y, q1.y, 0.001f) && + test_near(slerp_mid_edge.z, q1.z, 0.001f)); slerp_mid_edge = slerp(q1, q2, 1.0f); - assert(test_near(slerp_mid_edge.w, q2.w, 0.001f) && test_near(slerp_mid_edge.x, q2.x, 0.001f) && - test_near(slerp_mid_edge.y, q2.y, 0.001f) && test_near(slerp_mid_edge.z, q2.z, 0.001f)); + assert(test_near(slerp_mid_edge.w, q2.w, 0.001f) && + test_near(slerp_mid_edge.x, q2.x, 0.001f) && + test_near(slerp_mid_edge.y, q2.y, 0.001f) && + test_near(slerp_mid_edge.z, q2.z, 0.001f)); // FromTo quat from_to_test = @@ -174,8 +182,8 @@ void test_ease() { // Midpoint/Logic tests assert(ease::out_cubic(0.5f) > 0.5f); // Out curves should exceed linear value early - assert( - test_near(ease::in_out_quad(0.5f), 0.5f, 0.001f)); // Symmetric curves hit 0.5 at 0.5 + assert(test_near(ease::in_out_quad(0.5f), 0.5f, + 0.001f)); // Symmetric curves hit 0.5 at 0.5 assert(ease::out_expo(0.5f) > 0.5f); // Exponential out should be above linear } -- cgit v1.2.3