From e42734c3f3f669039f5e088371ab1ef8c7674bb5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 31 Jan 2013 22:58:27 +0100 Subject: test/test_pcm: merge source buffer generator --- test/test_pcm_pack.cxx | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'test/test_pcm_pack.cxx') 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 -/** - * 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(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(); 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; -- cgit v1.2.3