summaryrefslogtreecommitdiff
path: root/test/test_pcm_format.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-06 22:42:02 +0100
committerMax Kellermann <max@duempel.org>2014-01-06 23:08:49 +0100
commitc75339edcc8ced25a71ab96a309736986c04465b (patch)
tree59f152918425469f4da7ce08cf1954d326636688 /test/test_pcm_format.cxx
parentb0b7244b3aa238e22136fd16095e2b8d452b2cec (diff)
pcm/Format: change parameters/return values to ConstBuffer
Diffstat (limited to 'test/test_pcm_format.cxx')
-rw-r--r--test/test_pcm_format.cxx56
1 files changed, 21 insertions, 35 deletions
diff --git a/test/test_pcm_format.cxx b/test/test_pcm_format.cxx
index 49f4ccd4b..3b0dbb8fe 100644
--- a/test/test_pcm_format.cxx
+++ b/test/test_pcm_format.cxx
@@ -29,86 +29,72 @@
void
PcmFormatTest::TestFormat8to16()
{
- constexpr unsigned N = 256;
+ constexpr size_t N = 256;
const auto src = TestDataBuffer<int8_t, N>();
PcmBuffer buffer;
- size_t d_size;
PcmDither dither;
- auto d = pcm_convert_to_16(buffer, dither, SampleFormat::S8,
- src, sizeof(src), &d_size);
- auto d_end = pcm_end_pointer(d, d_size);
- CPPUNIT_ASSERT_EQUAL(N, unsigned(d_end - d));
+ auto d = pcm_convert_to_16(buffer, dither, SampleFormat::S8, src);
+ CPPUNIT_ASSERT_EQUAL(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(int(src[i]), d[i] >> 8);
+ CPPUNIT_ASSERT_EQUAL(int(src[i]), d.data[i] >> 8);
}
void
PcmFormatTest::TestFormat16to24()
{
- constexpr unsigned N = 256;
+ constexpr size_t N = 256;
const auto src = TestDataBuffer<int16_t, N>();
PcmBuffer buffer;
- size_t d_size;
- auto d = pcm_convert_to_24(buffer, SampleFormat::S16,
- src, sizeof(src), &d_size);
- auto d_end = pcm_end_pointer(d, d_size);
- CPPUNIT_ASSERT_EQUAL(N, unsigned(d_end - d));
+ auto d = pcm_convert_to_24(buffer, SampleFormat::S16, src);
+ CPPUNIT_ASSERT_EQUAL(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(int(src[i]), d[i] >> 8);
+ CPPUNIT_ASSERT_EQUAL(int(src[i]), d.data[i] >> 8);
}
void
PcmFormatTest::TestFormat16to32()
{
- constexpr unsigned N = 256;
+ constexpr size_t N = 256;
const auto src = TestDataBuffer<int16_t, N>();
PcmBuffer buffer;
- size_t d_size;
- auto d = pcm_convert_to_32(buffer, SampleFormat::S16,
- src, sizeof(src), &d_size);
- auto d_end = pcm_end_pointer(d, d_size);
- CPPUNIT_ASSERT_EQUAL(N, unsigned(d_end - d));
+ auto d = pcm_convert_to_32(buffer, SampleFormat::S16, src);
+ CPPUNIT_ASSERT_EQUAL(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(int(src[i]), d[i] >> 16);
+ CPPUNIT_ASSERT_EQUAL(int(src[i]), d.data[i] >> 16);
}
void
PcmFormatTest::TestFormatFloat()
{
- constexpr unsigned N = 256;
+ constexpr size_t N = 256;
const auto src = TestDataBuffer<int16_t, N>();
PcmBuffer buffer1, buffer2;
- size_t f_size;
- auto f = pcm_convert_to_float(buffer1, SampleFormat::S16,
- src, sizeof(src), &f_size);
- auto f_end = pcm_end_pointer(f, f_size);
- CPPUNIT_ASSERT_EQUAL(N, unsigned(f_end - f));
+ auto f = pcm_convert_to_float(buffer1, SampleFormat::S16, src);
+ CPPUNIT_ASSERT_EQUAL(N, f.size);
- for (auto i = f; i != f_end; ++i) {
- CPPUNIT_ASSERT(*i >= -1.);
- CPPUNIT_ASSERT(*i <= 1.);
+ for (size_t i = 0; i != f.size; ++i) {
+ CPPUNIT_ASSERT(f.data[i] >= -1.);
+ CPPUNIT_ASSERT(f.data[i] <= 1.);
}
PcmDither dither;
- size_t d_size;
auto d = pcm_convert_to_16(buffer2, dither,
SampleFormat::FLOAT,
- f, f_size, &d_size);
- auto d_end = pcm_end_pointer(d, d_size);
- CPPUNIT_ASSERT_EQUAL(N, unsigned(d_end - d));
+ f.ToVoid());
+ CPPUNIT_ASSERT_EQUAL(N, d.size);
for (size_t i = 0; i < N; ++i)
- CPPUNIT_ASSERT_EQUAL(src[i], d[i]);
+ CPPUNIT_ASSERT_EQUAL(src[i], d.data[i]);
}