summaryrefslogtreecommitdiff
path: root/test/test_pcm_channels.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-16 21:55:00 +0200
committerMax Kellermann <max@duempel.org>2013-10-16 23:36:36 +0200
commit401a799a1b5de5d70a6b4c1d49235af0d5618f37 (patch)
tree503db86df98400dac818fa3bbfbe20e2055a1fa4 /test/test_pcm_channels.cxx
parentba98518c69d0501e67ef707f0d718cc678851415 (diff)
test: use the CPPUNIT framework for unit tests
Diffstat (limited to 'test/test_pcm_channels.cxx')
-rw-r--r--test/test_pcm_channels.cxx38
1 files changed, 18 insertions, 20 deletions
diff --git a/test/test_pcm_channels.cxx b/test/test_pcm_channels.cxx
index 6642ed3d4..85c872674 100644
--- a/test/test_pcm_channels.cxx
+++ b/test/test_pcm_channels.cxx
@@ -23,10 +23,8 @@
#include "pcm/PcmChannels.hxx"
#include "pcm/PcmBuffer.hxx"
-#include <glib.h>
-
void
-test_pcm_channels_16()
+PcmChannelsTest::TestChannels16()
{
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int16_t, N * 2>();
@@ -39,26 +37,26 @@ test_pcm_channels_16()
const int16_t *dest =
pcm_convert_channels_16(buffer, 1, 2, src, sizeof(src),
&dest_size);
- g_assert(dest != NULL);
- g_assert_cmpint(dest_size, ==, sizeof(src) / 2);
+ CPPUNIT_ASSERT(dest != NULL);
+ CPPUNIT_ASSERT_EQUAL(sizeof(src) / 2, dest_size);
for (unsigned i = 0; i < N; ++i)
- g_assert_cmpint(dest[i], ==,
- (src[i * 2] + src[i * 2 + 1]) / 2);
+ CPPUNIT_ASSERT_EQUAL(int16_t((src[i * 2] + src[i * 2 + 1]) / 2),
+ dest[i]);
/* mono to stereo */
dest = pcm_convert_channels_16(buffer, 2, 1, src, sizeof(src),
&dest_size);
- g_assert(dest != NULL);
- g_assert_cmpint(dest_size, ==, sizeof(src) * 2);
+ CPPUNIT_ASSERT(dest != NULL);
+ CPPUNIT_ASSERT_EQUAL(sizeof(src) * 2, dest_size);
for (unsigned i = 0; i < N; ++i) {
- g_assert_cmpint(dest[i * 2], ==, src[i]);
- g_assert_cmpint(dest[i * 2 + 1], ==, src[i]);
+ CPPUNIT_ASSERT_EQUAL(src[i], dest[i * 2]);
+ CPPUNIT_ASSERT_EQUAL(src[i], dest[i * 2 + 1]);
}
}
void
-test_pcm_channels_32()
+PcmChannelsTest::TestChannels32()
{
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int32_t, N * 2>();
@@ -71,20 +69,20 @@ test_pcm_channels_32()
const int32_t *dest =
pcm_convert_channels_32(buffer, 1, 2, src, sizeof(src),
&dest_size);
- g_assert(dest != NULL);
- g_assert_cmpint(dest_size, ==, sizeof(src) / 2);
+ CPPUNIT_ASSERT(dest != NULL);
+ CPPUNIT_ASSERT_EQUAL(sizeof(src) / 2, dest_size);
for (unsigned i = 0; i < N; ++i)
- g_assert_cmpint(dest[i], ==,
- ((int64_t)src[i * 2] + (int64_t)src[i * 2 + 1]) / 2);
+ CPPUNIT_ASSERT_EQUAL(int32_t(((int64_t)src[i * 2] + (int64_t)src[i * 2 + 1]) / 2),
+ dest[i]);
/* mono to stereo */
dest = pcm_convert_channels_32(buffer, 2, 1, src, sizeof(src),
&dest_size);
- g_assert(dest != NULL);
- g_assert_cmpint(dest_size, ==, sizeof(src) * 2);
+ CPPUNIT_ASSERT(dest != NULL);
+ CPPUNIT_ASSERT_EQUAL(sizeof(src) * 2, dest_size);
for (unsigned i = 0; i < N; ++i) {
- g_assert_cmpint(dest[i * 2], ==, src[i]);
- g_assert_cmpint(dest[i * 2 + 1], ==, src[i]);
+ CPPUNIT_ASSERT_EQUAL(src[i], dest[i * 2]);
+ CPPUNIT_ASSERT_EQUAL(src[i], dest[i * 2 + 1]);
}
}