diff options
author | sanine <sanine.not@pm.me> | 2022-08-28 12:41:53 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-28 12:41:53 -0500 |
commit | 91726809f9e97d8d4fb7b6c0642234ff96535bdd (patch) | |
tree | 850fd9cc1f391744b48021b83e29e4bd961eda32 /src/channel.test.c | |
parent | 0d6ece00397ebb9215ccf1af06cce22c3a94197e (diff) |
add channel_init() and channel_reset()
Diffstat (limited to 'src/channel.test.c')
-rw-r--r-- | src/channel.test.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/channel.test.c b/src/channel.test.c index 96b7364..e7f7e06 100644 --- a/src/channel.test.c +++ b/src/channel.test.c @@ -1,6 +1,64 @@ #include "test/mossrose-test.h" +#include <plibsys.h> + +PMutex * mock_p_mutex_new_(); + +#define p_mutex_new mock_p_mutex_new_ +#include "channel.c" +#undef p_mutex_new + + +lily_mock_t *mock_p_mutex_new = NULL; +PMutex * mock_p_mutex_new_() +{ + mock_p_mutex_new->n_calls += 1; + return p_mutex_new(); +} + + +void test_channel_init() +{ + lily_mock_use(&mock_p_mutex_new); + + struct channel_t chan; + channel_init(&chan); + + lily_assert_int_equal(mock_p_mutex_new->n_calls, 1); + + lily_assert_int_equal(chan.active, false); + lily_assert_int_equal(chan.paused, false); + lily_assert_int_equal(chan.volume, 255); + lily_assert_int_equal(chan.pan, 0); + + lily_assert_null(chan.sound.left); + lily_assert_null(chan.sound.right); + lily_assert_int_equal(chan.pos, 0); +} + + +void test_channel_reset() +{ + struct channel_t chan; + chan.pos = 255; + chan.active = true; + chan.paused = true; + chan.volume = 5; + chan.pan = 30; + + channel_reset(&chan); + + lily_assert_int_equal(chan.pos, 0); + lily_assert_int_equal(chan.active, false); + lily_assert_int_equal(chan.paused, false); + lily_assert_int_equal(chan.volume, 255); + lily_assert_int_equal(chan.pan, 0); +} void suite_channel() { + lily_run_test(test_channel_init); + lily_run_test(test_channel_reset); + + lily_mock_destroy(mock_p_mutex_new); } |