aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pcm_util.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-02-01 15:52:03 +0100
committerMax Kellermann <max@duempel.org>2013-02-01 15:52:03 +0100
commita7a10d03c9bf8b6398408edaeae64ffb35a83bb3 (patch)
tree11337371be33f82be3a523e3890fbfa4515a83a1 /test/test_pcm_util.hxx
parentef99d6ce3d9b82cb249ae08b390049a6f9cd9d56 (diff)
downloadmpd-a7a10d03c9bf8b6398408edaeae64ffb35a83bb3.tar.gz
mpd-a7a10d03c9bf8b6398408edaeae64ffb35a83bb3.tar.xz
mpd-a7a10d03c9bf8b6398408edaeae64ffb35a83bb3.zip
test/test_pcm: add unit test for pcm_mix()
Diffstat (limited to '')
-rw-r--r--test/test_pcm_util.hxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test_pcm_util.hxx b/test/test_pcm_util.hxx
index c039d6560..84ba074fd 100644
--- a/test/test_pcm_util.hxx
+++ b/test/test_pcm_util.hxx
@@ -51,6 +51,7 @@ template<typename T, size_t N>
class TestDataBuffer : std::array<T, N> {
public:
using typename std::array<T, N>::const_pointer;
+ using std::array<T, N>::size;
using std::array<T, N>::begin;
using std::array<T, N>::end;
using std::array<T, N>::operator[];
@@ -66,3 +67,19 @@ public:
return begin();
}
};
+
+template<typename T>
+bool
+AssertEqualWithTolerance(const T &a, const T &b, unsigned tolerance)
+{
+ g_assert_cmpint(a.size(), ==, b.size());
+
+ for (unsigned i = 0; i < a.size(); ++i) {
+ int64_t x = a[i], y = b[i];
+
+ g_assert_cmpint(x, >=, y - int64_t(tolerance));
+ g_assert_cmpint(x, <=, y + int64_t(tolerance));
+ }
+
+ return true;
+}