#include "test/mossrose-test.h" #include 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); }