summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-04-22 09:50:39 +0200
committerMax Kellermann <max@musicpd.org>2017-04-24 11:32:52 +0200
commit803b73a34ba6c247b8f5f34ab6c8ba2be4c8013c (patch)
tree561100337c042ff3feae92d5af1e67c71fb3183b /test
parentb1512201ab59aca4a1197c793b643f363fceb5ad (diff)
pcm/PcmPack: add pcm_unpack_24be()
Diffstat (limited to 'test')
-rw-r--r--test/test_pcm_all.hxx2
-rw-r--r--test/test_pcm_pack.cxx20
2 files changed, 22 insertions, 0 deletions
diff --git a/test/test_pcm_all.hxx b/test/test_pcm_all.hxx
index ace822ab8..594012468 100644
--- a/test/test_pcm_all.hxx
+++ b/test/test_pcm_all.hxx
@@ -40,11 +40,13 @@ class PcmPackTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(PcmPackTest);
CPPUNIT_TEST(TestPack24);
CPPUNIT_TEST(TestUnpack24);
+ CPPUNIT_TEST(TestUnpack24BE);
CPPUNIT_TEST_SUITE_END();
public:
void TestPack24();
void TestUnpack24();
+ void TestUnpack24BE();
};
class PcmChannelsTest : public CppUnit::TestFixture {
diff --git a/test/test_pcm_pack.cxx b/test/test_pcm_pack.cxx
index fd92861b0..df3a99459 100644
--- a/test/test_pcm_pack.cxx
+++ b/test/test_pcm_pack.cxx
@@ -70,3 +70,23 @@ PcmPackTest::TestUnpack24()
CPPUNIT_ASSERT_EQUAL(s, dest[i]);
}
}
+
+void
+PcmPackTest::TestUnpack24BE()
+{
+ constexpr unsigned N = 509;
+ const auto src = TestDataBuffer<uint8_t, N * 3>();
+
+ int32_t dest[N];
+ pcm_unpack_24be(dest, src.begin(), src.end());
+
+ for (unsigned i = 0; i < N; ++i) {
+ int32_t s;
+ s = (src[i * 3] << 16) | (src[i * 3 + 1] << 8)
+ | src[i * 3 + 2];
+ if (s & 0x800000)
+ s |= 0xff000000;
+
+ CPPUNIT_ASSERT_EQUAL(s, dest[i]);
+ }
+}