From a7a10d03c9bf8b6398408edaeae64ffb35a83bb3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 1 Feb 2013 15:52:03 +0100 Subject: test/test_pcm: add unit test for pcm_mix() --- test/test_pcm_util.hxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/test_pcm_util.hxx') 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 class TestDataBuffer : std::array { public: using typename std::array::const_pointer; + using std::array::size; using std::array::begin; using std::array::end; using std::array::operator[]; @@ -66,3 +67,19 @@ public: return begin(); } }; + +template +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; +} -- cgit v1.2.3