From 401a799a1b5de5d70a6b4c1d49235af0d5618f37 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Oct 2013 21:55:00 +0200 Subject: test: use the CPPUNIT framework for unit tests --- test/test_pcm_channels.cxx | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'test/test_pcm_channels.cxx') 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 - void -test_pcm_channels_16() +PcmChannelsTest::TestChannels16() { constexpr unsigned N = 256; const auto src = TestDataBuffer(); @@ -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(); @@ -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]); } } -- cgit v1.2.3