diff options
author | Max Kellermann <max@duempel.org> | 2013-01-31 22:58:27 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-31 22:58:27 +0100 |
commit | e42734c3f3f669039f5e088371ab1ef8c7674bb5 (patch) | |
tree | 1f03b9b347f82e63ac6296b30d231345f21a0ef4 /test/test_pcm_pack.cxx | |
parent | eab78ab99c497b01ef1d5ec2ad3be74d61527cd1 (diff) | |
download | mpd-e42734c3f3f669039f5e088371ab1ef8c7674bb5.tar.gz mpd-e42734c3f3f669039f5e088371ab1ef8c7674bb5.tar.xz mpd-e42734c3f3f669039f5e088371ab1ef8c7674bb5.zip |
test/test_pcm: merge source buffer generator
Diffstat (limited to 'test/test_pcm_pack.cxx')
-rw-r--r-- | test/test_pcm_pack.cxx | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/test/test_pcm_pack.cxx b/test/test_pcm_pack.cxx index 61acf81ed..e23acad58 100644 --- a/test/test_pcm_pack.cxx +++ b/test/test_pcm_pack.cxx @@ -18,6 +18,7 @@ */ #include "test_pcm_all.hxx" +#include "test_pcm_util.hxx" extern "C" { #include "pcm_pack.h" @@ -25,29 +26,14 @@ extern "C" { #include <glib.h> -/** - * Generate a random 24 bit PCM sample. - */ -static int32_t -random24() -{ - int32_t x = g_random_int() & 0xffffff; - if (x & 0x800000) - x |= 0xff000000; - return x; -} - void test_pcm_pack_24() { - enum { N = 256 }; - int32_t src[N * 3]; - for (unsigned i = 0; i < N; ++i) - src[i] = random24(); + constexpr unsigned N = 256; + const auto src = TestDataBuffer<int32_t, N>(GlibRandomInt24()); uint8_t dest[N * 3]; - - pcm_pack_24(dest, src, src + N); + pcm_pack_24(dest, src.begin(), src.end()); for (unsigned i = 0; i < N; ++i) { int32_t d; @@ -67,14 +53,11 @@ test_pcm_pack_24() void test_pcm_unpack_24() { - enum { N = 256 }; - uint8_t src[N * 3]; - for (unsigned i = 0; i < G_N_ELEMENTS(src); ++i) - src[i] = g_random_int_range(0, 256); + constexpr unsigned N = 256; + const auto src = TestDataBuffer<uint8_t, N * 3>(); int32_t dest[N]; - - pcm_unpack_24(dest, src, src + G_N_ELEMENTS(src)); + pcm_unpack_24(dest, src.begin(), src.end()); for (unsigned i = 0; i < N; ++i) { int32_t s; |