[test_buffer]
improved check()
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user