[test_buffer]

use target and actual checks
This commit is contained in:
2025-11-05 08:23:09 +01:00
parent c627cd2dd7
commit 6f69217ba3
3 changed files with 21 additions and 7 deletions
+11 -4
View File
@@ -3,6 +3,7 @@
#include <cstdio>
#include <iostream>
#include <vector>
int test_buffer_1()
@@ -19,17 +20,23 @@ int test_buffer_1()
}
buffer += 5;
for (int i=-5; i < 5; i++)
dsp::Buffer<int> res_buf(5);
for (int i=0; i < res_buf.capacity(); i++)
{
int v = buffer[i];
int v = buffer[i-5];
res_buf[i] = v;
printf("i=%d: v=%d\n", i, v);
}
dsp::Buffer<int> t_buf{100, 101, 102, 103, 104};
check(res_buf, t_buf);
auto v1 = dsp::Buffer<int>(buffer, 0);
auto v2 = dsp::Buffer<int>(buffer, -5);
print(v1, v1.capacity());
print(v2, v2.capacity());
print(v1, v1.capacity(), "v1");
print(v2, v2.capacity(), "v2");
return 0;
}
+9 -2
View File
@@ -1,8 +1,9 @@
#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
@@ -20,8 +21,14 @@ void print(const dsp::Buffer<T> &v, size_t size, std::string name=std::string(""
}
template<typename T>
bool check(const dsp::Buffer<T> &target, const dsp::Buffer<T> &actual)
void check(const dsp::Buffer<T> &target, const dsp::Buffer<T> &actual)
{
if (!(target == actual))
{
std::cout << "Check failed" << std::endl;
print(target, target.capacity(), "Target");
print(actual, actual.capacity(), "Actual");
}
assert(target == actual);
}
+1 -1
View File
@@ -4,7 +4,7 @@ extern void test_buffer_multi();
int main()
{
test_buffer();
test_buffer_multi();
// test_buffer_multi();
return 0;
}