summaryrefslogtreecommitdiff
path: root/src/channel.test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/channel.test.c')
-rw-r--r--src/channel.test.c58
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);
}