- added MultiBuffer

- improved tests
This commit is contained in:
2025-10-27 21:48:51 +01:00
parent 9fedd040b3
commit 7f66f9e60d
7 changed files with 153 additions and 19 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ CC=clang
CCC=clang++
CXX=clang++
NAME := test_dsp_buffer
NAME := test_main
CONFIG ?= debug
TARGET ?= $(NAME)
@@ -13,7 +13,7 @@ CXXFLAGS += -std=c++20
INCLUDES += -I $(realpath .) -I $(realpath ../../)
CXX_SRCS := test_buffer.cpp
CXX_SRCS := test_main.cpp test_buffer.cpp test_buffer_multi.cpp
LIBS := -lstdc++
+19 -5
View File
@@ -7,10 +7,10 @@
template<typename T>
void print(dsp::BufferView<T> &v, size_t size)
{
// for(const auto&i : v)
// {
// std::cout << i << std::endl;
// }
for(const auto&i : v)
{
std::cout << i << std::endl;
}
std::cout << "----------------------------------------------" << std::endl;
for (int i=0; i < size; i++)
{
@@ -19,8 +19,17 @@ void print(dsp::BufferView<T> &v, size_t size)
}
int main()
static void info()
{
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Start test_buffer()" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
}
int test_buffer()
{
info();
dsp::Buffer<int> buffer(10);
printf("Buffer capacity = %zu\n", buffer.capacity());
for (int i=0; i < 10; i++)
@@ -44,5 +53,10 @@ int main()
v2[2] = 77;
print(v2,10);
for(const auto&i : buffer)
{
std::cout << i+100 << std::endl;
}
return 0;
}
+44
View File
@@ -0,0 +1,44 @@
#include <delay/buffer_multi.hpp>
#include <cstdio>
#include <iostream>
static void info()
{
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Start test_buffer_multi()" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
}
int test_buffer_multi()
{
info();
dsp::BufferMulti<int>buffer(5, 20);
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;
}
+10
View File
@@ -0,0 +1,10 @@
extern void test_buffer();
extern void test_buffer_multi();
int main()
{
test_buffer();
test_buffer_multi();
return 0;
}