improved buffer tests
This commit is contained in:
+21
-25
@@ -13,33 +13,37 @@ int test_buffer_1()
|
||||
std::cout << "----------------------------------------------" << std::endl;
|
||||
|
||||
dsp::Buffer<int> buffer(10);
|
||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||
for (int i=0; i < buffer.capacity(); i++)
|
||||
{
|
||||
buffer[i] = i+100;
|
||||
}
|
||||
buffer += 5;
|
||||
|
||||
{
|
||||
dsp::Buffer<int> t_buf{105, 106, 107, 108, 109};
|
||||
check(buffer, t_buf, t_buf.capacity());
|
||||
}
|
||||
|
||||
dsp::Buffer<int> res_buf(5);
|
||||
for (int i=0; i < res_buf.capacity(); i++)
|
||||
{
|
||||
int v = buffer[i-5];
|
||||
res_buf[i] = v;
|
||||
}
|
||||
dsp::Buffer<int> t_buf{100, 101, 102, 103, 104};
|
||||
|
||||
|
||||
check(res_buf, t_buf);
|
||||
{
|
||||
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(), "v1");
|
||||
print(v2, v2.capacity(), "v2");
|
||||
buffer.reset();
|
||||
{
|
||||
dsp::Buffer<int> t_buf{100, 101, 102, 103, 104, 105, 106, 107, 108, 109};
|
||||
check(dsp::Buffer<int>(buffer, 0), t_buf);
|
||||
}
|
||||
{
|
||||
dsp::Buffer<int> t_buf{0, 0, 0, 0, 0, 100, 101, 102, 103, 104};
|
||||
check(dsp::Buffer<int>(buffer, -5), t_buf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -50,27 +54,20 @@ int test_buffer_2()
|
||||
std::cout << "Start test_buffer_2" << std::endl;
|
||||
std::cout << "----------------------------------------------" << std::endl;
|
||||
|
||||
dsp::Buffer<int> buffer(5);
|
||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||
dsp::Buffer<int> buffer(10);
|
||||
for (int i=0; i < buffer.capacity(); i++)
|
||||
{
|
||||
buffer[i] = i+100;
|
||||
}
|
||||
const auto v1 = dsp::Buffer<int>(buffer, -1);
|
||||
const auto v2 = dsp::Buffer<int>(buffer, -5);
|
||||
|
||||
for(int i=0; i < buffer.capacity(); i++)
|
||||
{
|
||||
std::cout << buffer[i] << std::endl;
|
||||
dsp::Buffer<int> t_buf{0, 100, 101, 102, 103, 104, 105, 106, 107, 108};
|
||||
check(dsp::Buffer<int>(buffer, -1), t_buf);
|
||||
}
|
||||
{
|
||||
dsp::Buffer<int> t_buf{0, 0, 0, 0, 0, 100, 101, 102, 103, 104};
|
||||
check(dsp::Buffer<int>(buffer, -5), t_buf);
|
||||
}
|
||||
|
||||
std::cout << "print(buffer, 10);" << std::endl;
|
||||
print(buffer, 10);
|
||||
std::cout << "print(v1, 10);" << std::endl;
|
||||
print(v1, 10);
|
||||
std::cout << "print(v2, 10);" << std::endl;
|
||||
print(v2, 10);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -82,7 +79,6 @@ int test_buffer_3()
|
||||
std::cout << "----------------------------------------------" << std::endl;
|
||||
|
||||
dsp::Buffer<int> buffer(50);
|
||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||
for (int i=0; i < buffer.capacity(); i++)
|
||||
{
|
||||
buffer[i] = i+100;
|
||||
|
||||
Reference in New Issue
Block a user