[test_buffer]

improved check()
This commit is contained in:
2025-11-05 09:04:11 +01:00
parent bb873d49d4
commit 3ee368f484
2 changed files with 34 additions and 16 deletions
+27 -3
View File
@@ -1,3 +1,4 @@
#include <cmath>
#include <delay/buffer_multi.hpp>
#include <delay/buffer.hpp>
#include <cstdio>
@@ -21,15 +22,38 @@ void print(const dsp::Buffer<T> &v, size_t size, std::string name=std::string(""
}
template<typename T>
void check(const dsp::Buffer<T> &target, const dsp::Buffer<T> &actual)
void check(const dsp::Buffer<T> &target, const dsp::Buffer<T> &actual, size_t size=0)
{
if (!(target == actual))
bool success = false;
do
{
if (size == 0)
{
if (target.capacity() != actual.capacity())
{
break;
}
size = target.capacity();
}
for (int i=0; i < size; i++)
{
if (target[i] != actual[i])
{
break;
}
}
success = true;
} while(false);
if (!success)
{
std::cout << "Check failed" << std::endl;
print(target, target.capacity(), "Target");
print(actual, actual.capacity(), "Actual");
}
assert(target == actual);
assert(success);
}
#endif