108 lines
2.0 KiB
C++
108 lines
2.0 KiB
C++
#include <delay/buffer_multi.hpp>
|
|
#include <cstdio>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
int test_buffer_multi_1()
|
|
{
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
std::cout << "Start test_buffer_multi_1()" << std::endl;
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
|
|
dsp::BufferMulti<int>buffer(5, 10);
|
|
printf("Buffer capacity = %zu\n", buffer.capacity());
|
|
|
|
for (int i=0; i < 10; i++)
|
|
{
|
|
for (int c=0; c < 5; c++)
|
|
{
|
|
buffer.at(c, 0) = i+1;
|
|
}
|
|
buffer += 1;
|
|
|
|
}
|
|
|
|
buffer.reset();
|
|
for (int i=0; i < 10; i++)
|
|
{
|
|
for (int c=0; c < 5; c++)
|
|
{
|
|
int v = buffer.at(c, i);
|
|
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
|
}
|
|
}
|
|
|
|
for(const auto&i : buffer)
|
|
{
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int test_buffer_multi_2()
|
|
{
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
std::cout << "Start test_buffer_multi_2()" << std::endl;
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
|
|
dsp::BufferMulti<int>buffer(5, 3);
|
|
printf("Buffer capacity = %zu\n", buffer.capacity());
|
|
|
|
for (int i=0; i < 10; i++)
|
|
{
|
|
for (int c=0; c < 5; c++)
|
|
{
|
|
buffer.at(c, 0) = i+1;
|
|
int v = buffer.at(c, -2);
|
|
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
|
}
|
|
buffer += 1;
|
|
|
|
}
|
|
|
|
#if 0
|
|
buffer.reset();
|
|
for (int i=0; i < 10; i++)
|
|
{
|
|
for (int c=0; c < 5; c++)
|
|
{
|
|
int v = buffer.at(c, i);
|
|
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
|
}
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
int test_buffer_multi_3()
|
|
{
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
std::cout << "Start test_buffer_multi_3()" << std::endl;
|
|
std::cout << "----------------------------------------------" << std::endl;
|
|
|
|
dsp::BufferMulti<int>buffer(5, 10);
|
|
printf("Buffer capacity = %zu\n", buffer.capacity());
|
|
|
|
for (int i=0; i < 20; i++)
|
|
{
|
|
for (int c=0; c < 5; c++)
|
|
{
|
|
buffer.at(c, 0) = i+1;
|
|
int v = buffer.at(c, -c);
|
|
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
|
}
|
|
buffer += 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int test_buffer_multi()
|
|
{
|
|
test_buffer_multi_1();
|
|
test_buffer_multi_2();
|
|
test_buffer_multi_3();
|
|
|
|
return 0;
|
|
}
|