diff options
author | sanine <sanine.not@pm.me> | 2022-09-03 21:32:25 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-09-03 21:32:25 -0500 |
commit | 2cf000fb7cbe653c2e96e0b3b8f3c1425401d3fc (patch) | |
tree | e172ef67b253d1eaa0fb22186b5901edd4de793a /src/channel.test.c | |
parent | a416cfb6881b8ff99c29ba87c1d940d6143e44b1 (diff) |
add looping
Diffstat (limited to 'src/channel.test.c')
-rw-r--r-- | src/channel.test.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/src/channel.test.c b/src/channel.test.c index 4591b43..067879f 100644 --- a/src/channel.test.c +++ b/src/channel.test.c @@ -71,15 +71,11 @@ void test_channel_init() } -void test_channel_reset() +void test_channel_reset_last_loop() { struct channel_t chan; - chan.pos = 255; chan.shared.active = true; - chan.shared.paused = true; - chan.shared.volume = 5; - chan.shared.pan_left = 30; - chan.shared.pan_right = 30; + chan.shared.loops = 1; channel_reset(&chan); @@ -87,6 +83,36 @@ void test_channel_reset() } +void test_channel_reset_penultimate_loop() +{ + struct channel_t chan; + chan.shared.active = true; + chan.shared.loops = 2; + chan.pos = 98; + + channel_reset(&chan); + + lily_assert_int_equal(chan.shared.active, true); + lily_assert_int_equal(chan.shared.loops, 1); + lily_assert_int_equal(chan.pos, 0); +} + + +void test_channel_reset_infinite_loop() +{ + struct channel_t chan; + chan.shared.active = true; + chan.shared.loops = 0; + chan.pos = 17; + + channel_reset(&chan); + + lily_assert_int_equal(chan.shared.active, true); + lily_assert_int_equal(chan.shared.loops, 0); + lily_assert_int_equal(chan.pos, 0); +} + + void test_channel_pause() { struct channel_t chan; @@ -180,7 +206,7 @@ void test_channel_sound_load() chan.sound.right = NULL; chan.pos = 5; - int result = channel_sound_load(&chan, &sound, false); + int result = channel_sound_load(&chan, &sound, false, 1); lily_assert_int_equal(mock_p_mutex_lock->n_calls, 1); lily_assert_int_equal(mock_p_mutex_unlock->n_calls, 1); @@ -216,7 +242,7 @@ void test_channel_sound_load_mono() chan.sound.left = NULL; chan.sound.right = NULL; - int result = channel_sound_load(&chan, &sound, false); + int result = channel_sound_load(&chan, &sound, false, 1); lily_assert_int_equal(mock_p_mutex_lock->n_calls, 1); lily_assert_int_equal(mock_p_mutex_unlock->n_calls, 1); @@ -256,7 +282,7 @@ void test_channel_sound_load_preserve() chan.shared.pan_left = 0; chan.shared.pan_right = 64; - int result = channel_sound_load(&chan, &sound, true); + int result = channel_sound_load(&chan, &sound, true, 1); lily_assert_int_equal(mock_p_mutex_lock->n_calls, 1); lily_assert_int_equal(mock_p_mutex_unlock->n_calls, 1); @@ -299,7 +325,7 @@ void test_channel_sound_fail() chan.sound.mono = true; chan.pos = 6; - int result = channel_sound_load(&chan, &sound, false); + int result = channel_sound_load(&chan, &sound, false, 1); lily_assert_int_equal(mock_p_mutex_lock->n_calls, 0); lily_assert_int_equal(mock_p_mutex_unlock->n_calls, 0); @@ -391,6 +417,7 @@ void test_channel_get_next_sample_normal() struct channel_t chan; chan.shared.active = true; chan.shared.paused = false; + chan.shared.loops = 1; chan.shared.volume = 255; chan.shared.pan_left = -128; chan.shared.pan_right = 128; @@ -441,6 +468,7 @@ void test_channel_get_next_sample_volume_0() struct channel_t chan; chan.shared.active = true; chan.shared.paused = false; + chan.shared.loops = 1; chan.shared.volume = 0; chan.shared.pan_left = -128; chan.shared.pan_right = 128; @@ -491,6 +519,7 @@ void test_channel_get_next_sample_mono() struct channel_t chan; chan.shared.active = true; chan.shared.paused = false; + chan.shared.loops = 1; chan.shared.volume = 255; chan.shared.pan_left = 0; chan.shared.pan_right = 128; @@ -542,6 +571,7 @@ void test_channel_get_next_sample_mono_panned() struct channel_t chan; chan.shared.active = true; chan.shared.paused = false; + chan.shared.loops = 1; chan.shared.volume = 255; chan.shared.pan_left = -128; chan.shared.pan_right = 128; @@ -591,6 +621,7 @@ void test_channel_get_next_sample_panned() struct channel_t chan; chan.shared.active = true; chan.shared.paused = false; + chan.shared.loops = 1; chan.shared.volume = 255; chan.shared.pan_left = 128; chan.shared.pan_right = 0; @@ -638,12 +669,15 @@ void test_channel_get_next_sample_panned() void suite_channel() { lily_run_test(test_channel_init); - lily_run_test(test_channel_reset); lily_run_test(test_channel_pause); lily_run_test(test_channel_resume); lily_run_test(test_channel_set_volume); lily_run_test(test_channel_set_pan); + lily_run_test(test_channel_reset_last_loop); + lily_run_test(test_channel_reset_penultimate_loop); + lily_run_test(test_channel_reset_infinite_loop); + lily_run_test(test_channel_sound_load); lily_run_test(test_channel_sound_load_mono); lily_run_test(test_channel_sound_load_preserve); |