Files
dsp/tests/test_common.hpp
jens 681290c9ae - refactored
- BufferMulti numChannels is template parameter
2025-11-09 13:20:16 +01:00

69 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)
{
for(int i=0; i < size; i++)
{
std::cout << v[i] << " ";
}
std::cout << std::endl;
}
template<typename T>
void print(T *v, size_t size)
{
for(int i=0; i < size; i++)
{
std::cout << v[i] << " ";
}
std::cout << 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;
std::cout << "Target" << std::endl;
print(target, target.capacity());
std::cout << "Actual" << std::endl;
print(actual, actual.capacity());
}
assert(success);
}
#endif