diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-14 02:39:49 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-14 02:39:49 +0100 |
| commit | 8dd77545b5ec2f45ce46b98dd7d94a3c4a13e290 (patch) | |
| tree | a338b9c1356da64a609621155c81d8d96f7ca7fe /src/tests/audio/test_wav_dump.cc | |
| parent | c007d7fa6ddb1936108aeca156b2a4bda425ca84 (diff) | |
Refactor duplicated test setup/teardown code into shared fixtures:
- test_math_helpers.h: Float comparison (test_near, test_near_vec3)
- AudioTestFixture: RAII wrapper for AudioEngine lifecycle
- EffectTestFixture: Combined WebGPU + AudioEngine + MainSequence
Migrated 9 test files (3 math, 6 audio) to use fixtures.
Net reduction: 54 LOC (178 insertions, 232 deletions).
All 34 tests passing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tests/audio/test_wav_dump.cc')
| -rw-r--r-- | src/tests/audio/test_wav_dump.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/tests/audio/test_wav_dump.cc b/src/tests/audio/test_wav_dump.cc index 85b168d..9175153 100644 --- a/src/tests/audio/test_wav_dump.cc +++ b/src/tests/audio/test_wav_dump.cc @@ -5,6 +5,7 @@ #include "audio/audio_engine.h" #include "audio/backend/wav_dump_backend.h" #include "audio/ring_buffer.h" +#include "../common/audio_test_fixture.h" #include <assert.h> #include <stdio.h> #include <string.h> @@ -38,8 +39,7 @@ void test_wav_format_matches_live_audio() { audio_init(); // Initialize AudioEngine - AudioEngine engine; - engine.init(); + AudioTestFixture fixture; // Create WAV dump backend WavDumpBackend wav_backend; @@ -59,7 +59,7 @@ void test_wav_format_matches_live_audio() { float music_time = 0.0f; for (float t = 0.0f; t < duration; t += update_dt) { // Update audio engine (triggers patterns) - engine.update(music_time, update_dt); + fixture.engine().update(music_time, update_dt); music_time += update_dt; // Render audio ahead @@ -76,7 +76,6 @@ void test_wav_format_matches_live_audio() { // Shutdown wav_backend.shutdown(); - engine.shutdown(); audio_shutdown(); // Read and verify WAV header @@ -192,8 +191,7 @@ void test_clipping_detection() { const char* test_file = "test_clipping.wav"; audio_init(); - AudioEngine engine; - engine.init(); + AudioTestFixture fixture; WavDumpBackend wav_backend; wav_backend.set_output_file(test_file); @@ -225,7 +223,6 @@ void test_clipping_detection() { printf(" Detected %zu clipped samples (expected 200)\n", clipped); wav_backend.shutdown(); - engine.shutdown(); audio_shutdown(); // Clean up |
