59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
#include <cmath>
|
|
#include <delay/buffer_multi.hpp>
|
|
#include <delay/buffer.hpp>
|
|
#include <cstdio>
|
|
#include <assert.h>
|
|
#include <iostream>
|
|
#include <ostream>
|
|
|
|
#ifndef TEST_COMMON_H
|
|
#define TEST_COMMON_H
|
|
|
|
template<typename T>
|
|
void print(const dsp::Buffer<T> &v, size_t size, std::string name=std::string(""))
|
|
{
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
std::cout << "- " << name << std::endl;
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
for(int i=0; i < size; i++)
|
|
{
|
|
std::cout << v[i] << std::endl;
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
void check(const dsp::Buffer<T> &target, const dsp::Buffer<T> &actual, size_t size=0)
|
|
{
|
|
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(success);
|
|
}
|
|
|
|
#endif |