diff options
Diffstat (limited to 'src/channel.test.c')
-rw-r--r-- | src/channel.test.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/channel.test.c b/src/channel.test.c index 4fddf45..2c5cdad 100644 --- a/src/channel.test.c +++ b/src/channel.test.c @@ -103,6 +103,50 @@ void test_channel_resume() } +void test_channel_set_volume() +{ + struct channel_t chan; + chan.volume = 255; + + channel_set_volume(&chan, 0.0f); + lily_assert_int_equal(chan.volume, 0); + channel_set_volume(&chan, 0.5f); + lily_assert_int_equal(chan.volume, 127); + channel_set_volume(&chan, 1.0f); + lily_assert_int_equal(chan.volume, 255); + + /* oob */ + channel_set_volume(&chan, -1.0f); + lily_assert_int_equal(chan.volume, 0); + channel_set_volume(&chan, 2.0f); + lily_assert_int_equal(chan.volume, 255); +} + + +void test_channel_set_pan() +{ + struct channel_t chan; + chan.pan = 255; + + channel_set_pan(&chan, -1.0f); + lily_assert_int_equal(chan.pan, -128); + channel_set_pan(&chan, -0.5f); + lily_assert_int_equal(chan.pan, -64); + channel_set_pan(&chan, 0.0f); + lily_assert_int_equal(chan.pan, 0); + channel_set_pan(&chan, 0.5f); + lily_assert_int_equal(chan.pan, 64); + channel_set_pan(&chan, 1.0f); + lily_assert_int_equal(chan.pan, 128); + + /* oob */ + channel_set_pan(&chan, -10.0f); + lily_assert_int_equal(chan.pan, -128); + channel_set_pan(&chan, 2.0f); + lily_assert_int_equal(chan.pan, 128); +} + + /* get_next_sample tests */ void test_channel_get_next_sample_inactive() { @@ -217,6 +261,8 @@ void suite_channel() 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_get_next_sample_inactive); lily_run_test(test_channel_get_next_sample_paused); |