summaryrefslogtreecommitdiff
path: root/test/test_pcm_format.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-10-16 19:01:13 +0200
committerMax Kellermann <max@musicpd.org>2018-10-16 21:26:04 +0200
commit01b6e1cbf28f54793e22cc40affac7fb03511180 (patch)
tree5ac27527b2c5f36384f2c42d3907f12fa96067af /test/test_pcm_format.cxx
parenteefc0f5d80fbcb485db230c3df090b69994a75ce (diff)
test: use GTest instead of cppunit
Diffstat (limited to 'test/test_pcm_format.cxx')
-rw-r--r--test/test_pcm_format.cxx49
1 files changed, 23 insertions, 26 deletions
diff --git a/test/test_pcm_format.cxx b/test/test_pcm_format.cxx
index 728e3c1f2..63f30bef9 100644
--- a/test/test_pcm_format.cxx
+++ b/test/test_pcm_format.cxx
@@ -18,7 +18,6 @@
*/
#include "config.h"
-#include "test_pcm_all.hxx"
#include "test_pcm_util.hxx"
#include "pcm/PcmFormat.hxx"
#include "pcm/PcmDither.hxx"
@@ -26,8 +25,9 @@
#include "pcm/PcmBuffer.hxx"
#include "pcm/SampleFormat.hxx"
-void
-PcmFormatTest::TestFormat8to16()
+#include <gtest/gtest.h>
+
+TEST(PcmTest, Format8To16)
{
constexpr size_t N = 509;
const auto src = TestDataBuffer<int8_t, N>();
@@ -36,14 +36,13 @@ PcmFormatTest::TestFormat8to16()
PcmDither dither;
auto d = pcm_convert_to_16(buffer, dither, SampleFormat::S8, src);
- CPPUNIT_ASSERT_EQUAL(N, d.size);
+ EXPECT_EQ(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(int(src[i]), d[i] >> 8);
+ EXPECT_EQ(int(src[i]), d[i] >> 8);
}
-void
-PcmFormatTest::TestFormat16to24()
+TEST(PcmTest, Format16To24)
{
constexpr size_t N = 509;
const auto src = TestDataBuffer<int16_t, N>();
@@ -51,14 +50,13 @@ PcmFormatTest::TestFormat16to24()
PcmBuffer buffer;
auto d = pcm_convert_to_24(buffer, SampleFormat::S16, src);
- CPPUNIT_ASSERT_EQUAL(N, d.size);
+ EXPECT_EQ(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(int(src[i]), d[i] >> 8);
+ EXPECT_EQ(int(src[i]), d[i] >> 8);
}
-void
-PcmFormatTest::TestFormat16to32()
+TEST(PcmTest, Format16To32)
{
constexpr size_t N = 509;
const auto src = TestDataBuffer<int16_t, N>();
@@ -66,14 +64,13 @@ PcmFormatTest::TestFormat16to32()
PcmBuffer buffer;
auto d = pcm_convert_to_32(buffer, SampleFormat::S16, src);
- CPPUNIT_ASSERT_EQUAL(N, d.size);
+ EXPECT_EQ(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(int(src[i]), d[i] >> 16);
+ EXPECT_EQ(int(src[i]), d[i] >> 16);
}
-void
-PcmFormatTest::TestFormatFloat()
+TEST(PcmTest, FormatFloat)
{
constexpr size_t N = 509;
const auto src = TestDataBuffer<int16_t, N>();
@@ -81,11 +78,11 @@ PcmFormatTest::TestFormatFloat()
PcmBuffer buffer1, buffer2;
auto f = pcm_convert_to_float(buffer1, SampleFormat::S16, src);
- CPPUNIT_ASSERT_EQUAL(N, f.size);
+ EXPECT_EQ(N, f.size);
for (size_t i = 0; i != f.size; ++i) {
- CPPUNIT_ASSERT(f[i] >= -1.);
- CPPUNIT_ASSERT(f[i] <= 1.);
+ EXPECT_GE(f[i], -1.);
+ EXPECT_LE(f[i], 1.);
}
PcmDither dither;
@@ -93,10 +90,10 @@ PcmFormatTest::TestFormatFloat()
auto d = pcm_convert_to_16(buffer2, dither,
SampleFormat::FLOAT,
f.ToVoid());
- CPPUNIT_ASSERT_EQUAL(N, d.size);
+ EXPECT_EQ(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(src[i], d[i]);
+ EXPECT_EQ(src[i], d[i]);
/* check if clamping works */
float *writable = const_cast<float *>(f.data);
@@ -108,13 +105,13 @@ PcmFormatTest::TestFormatFloat()
d = pcm_convert_to_16(buffer2, dither,
SampleFormat::FLOAT,
f.ToVoid());
- CPPUNIT_ASSERT_EQUAL(N, d.size);
+ EXPECT_EQ(N, d.size);
- CPPUNIT_ASSERT_EQUAL(32767, int(d[0]));
- CPPUNIT_ASSERT_EQUAL(32767, int(d[1]));
- CPPUNIT_ASSERT_EQUAL(-32768, int(d[2]));
- CPPUNIT_ASSERT_EQUAL(-32768, int(d[3]));
+ EXPECT_EQ(32767, int(d[0]));
+ EXPECT_EQ(32767, int(d[1]));
+ EXPECT_EQ(-32768, int(d[2]));
+ EXPECT_EQ(-32768, int(d[3]));
for (size_t i = 4; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(src[i], d[i]);
+ EXPECT_EQ(src[i], d[i]);
}