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_silent_backend.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_silent_backend.cc')
| -rw-r--r-- | src/tests/audio/test_silent_backend.cc | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/tests/audio/test_silent_backend.cc b/src/tests/audio/test_silent_backend.cc index 8daacf7..cc98139 100644 --- a/src/tests/audio/test_silent_backend.cc +++ b/src/tests/audio/test_silent_backend.cc @@ -6,6 +6,7 @@ #include "audio/audio_engine.h" #include "audio/backend/silent_backend.h" #include "audio/synth.h" +#include "../common/audio_test_fixture.h" #include <assert.h> #include <stdio.h> @@ -80,8 +81,7 @@ void test_silent_backend_tracking() { SilentBackend backend; audio_set_backend(&backend); - AudioEngine engine; - engine.init(); + AudioTestFixture fixture; // Initial state assert(backend.get_frames_rendered() == 0); @@ -105,7 +105,6 @@ void test_silent_backend_tracking() { assert(backend.get_frames_rendered() == 0); assert(backend.get_voice_trigger_count() == 0); - engine.shutdown(); audio_shutdown(); printf("SilentBackend tracking test PASSED\n"); @@ -116,8 +115,7 @@ void test_audio_playback_time() { SilentBackend backend; audio_set_backend(&backend); - AudioEngine engine; - engine.init(); + AudioTestFixture fixture; audio_start(); // Initial playback time should be 0 @@ -137,7 +135,6 @@ void test_audio_playback_time() { float t2 = audio_get_playback_time(); assert(t2 >= t1); // Should continue advancing - engine.shutdown(); audio_shutdown(); printf("Audio playback time test PASSED\n"); @@ -148,8 +145,7 @@ void test_audio_buffer_partial_writes() { SilentBackend backend; audio_set_backend(&backend); - AudioEngine engine; - engine.init(); + AudioTestFixture fixture; audio_start(); // Fill buffer multiple times to test wraparound @@ -164,7 +160,6 @@ void test_audio_buffer_partial_writes() { // no audio callback to consume from the ring buffer audio_update(); // Should not crash - engine.shutdown(); audio_shutdown(); printf("Audio buffer partial writes test PASSED\n"); @@ -175,8 +170,7 @@ void test_audio_update() { SilentBackend backend; audio_set_backend(&backend); - AudioEngine engine; - engine.init(); + AudioTestFixture fixture; audio_start(); // audio_update() should be callable without crashing @@ -184,7 +178,6 @@ void test_audio_update() { audio_update(); audio_update(); - engine.shutdown(); audio_shutdown(); printf("Audio update test PASSED\n"); |
