summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-05-26 16:50:30 +0200
committerMax Kellermann <max@musicpd.org>2020-05-26 16:50:40 +0200
commit210c270624c3f8d7c0e8484a992c82ef09f8ad0f (patch)
treeb9575903b97a31cf7b50ff9c4643d2e304dd4ff2
parentbe94b4373a6ab4455a36ffa5bdee0448bb47dbe0 (diff)
test/test_pcm_export: eliminate zero-length arrays
C++ doesn't allow that. Closes https://github.com/MusicPlayerDaemon/MPD/issues/875
-rw-r--r--test/test_pcm_export.cxx20
1 files changed, 5 insertions, 15 deletions
diff --git a/test/test_pcm_export.cxx b/test/test_pcm_export.cxx
index f69882737..294a8890c 100644
--- a/test/test_pcm_export.cxx
+++ b/test/test_pcm_export.cxx
@@ -205,10 +205,8 @@ TEST(PcmTest, ExportDsdU16)
/* no output, 2/4 remains */
static constexpr uint8_t src2[] = { 0x11, 0x22 };
- static constexpr uint16_t expected2[] = {};
dest = e.Export({src2, sizeof(src2)});
- EXPECT_EQ(sizeof(expected2), dest.size);
- EXPECT_TRUE(memcmp(dest.data, expected2, dest.size) == 0);
+ EXPECT_TRUE(dest.empty());
/* one full frame and 2/4 remains */
static constexpr uint8_t src3[] = { 0x33, 0x44, 0x55, 0x66 };
@@ -267,10 +265,8 @@ TEST(PcmTest, ExportDsdU32)
/* no output, 4/8 remains */
static constexpr uint8_t src2[] = { 0x11, 0x22, 0x33, 0x44 };
- static constexpr uint32_t expected2[] = {};
dest = e.Export({src2, sizeof(src2)});
- EXPECT_EQ(sizeof(expected2), dest.size);
- EXPECT_TRUE(memcmp(dest.data, expected2, dest.size) == 0);
+ EXPECT_TRUE(dest.empty());
/* one full frame and 4/8 remains */
static constexpr uint8_t src3[] = { 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc };
@@ -327,17 +323,13 @@ TEST(PcmTest, ExportDop)
/* not enough data: 2/8 */
static constexpr uint8_t src2[] = { 0x12, 0x34 };
- static constexpr uint32_t expected2[] = {};
dest = e.Export({src2, sizeof(src2)});
- ASSERT_EQ(sizeof(expected2), dest.size);
- ASSERT_TRUE(memcmp(dest.data, expected2, dest.size) == 0);
+ ASSERT_EQ(dest.size, 0u);
/* not enough data: 6/8 */
static constexpr uint8_t src3[] = { 0x56, 0x78, 0x9a, 0xbc };
- static constexpr uint32_t expected3[] = {};
dest = e.Export({src3, sizeof(src3)});
- ASSERT_EQ(sizeof(expected3), dest.size);
- ASSERT_TRUE(memcmp(dest.data, expected3, dest.size) == 0);
+ ASSERT_EQ(dest.size, 0u);
/* just enough data: 8/8 */
static constexpr uint8_t src4[] = { 0xde, 0xf0 };
@@ -348,10 +340,8 @@ TEST(PcmTest, ExportDop)
/* not enough data: 6/8 */
static constexpr uint8_t src5[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
- static constexpr uint32_t expected5[] = {};
dest = e.Export({src5, sizeof(src5)});
- ASSERT_EQ(sizeof(expected5), dest.size);
- ASSERT_TRUE(memcmp(dest.data, expected5, dest.size) == 0);
+ ASSERT_TRUE(dest.empty());
/* two quads returned, not enough data for more: 2/8 */
static constexpr uint8_t src6[] = { 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x10, 0x20 };