improved buffer tests
This commit is contained in:
@@ -15,7 +15,7 @@ int test_buffer_1()
|
|||||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||||
for (int i=0; i < 10; i++)
|
for (int i=0; i < 10; i++)
|
||||||
{
|
{
|
||||||
buffer[i] = i+1;
|
buffer[i] = i+100;
|
||||||
}
|
}
|
||||||
buffer += 5;
|
buffer += 5;
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ int test_buffer_2()
|
|||||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||||
for (int i=0; i < 10; i++)
|
for (int i=0; i < 10; i++)
|
||||||
{
|
{
|
||||||
buffer[i] = i+1;
|
buffer[i] = i+100;
|
||||||
}
|
}
|
||||||
buffer += 5;
|
buffer += 5;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ int test_buffer_3()
|
|||||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||||
for (int i=0; i < buffer.capacity(); i++)
|
for (int i=0; i < buffer.capacity(); i++)
|
||||||
{
|
{
|
||||||
buffer[i] = i;
|
buffer[i] = i+100;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
@@ -96,7 +96,7 @@ int test_buffer_3()
|
|||||||
std::cout << "offset = " << offset << std::endl;
|
std::cout << "offset = " << offset << std::endl;
|
||||||
std::cout << "----------------------------------------------" << std::endl;
|
std::cout << "----------------------------------------------" << std::endl;
|
||||||
auto v1 = dsp::Buffer<int>(buffer, offset, incr);
|
auto v1 = dsp::Buffer<int>(buffer, offset, incr);
|
||||||
for(int i=0; i < v1.capacity()/incr; i++)
|
for(int i=0; i < v1.capacity(); i++)
|
||||||
{
|
{
|
||||||
std::cout << v1[i] << std::endl;
|
std::cout << v1[i] << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ int test_buffer_multi_1()
|
|||||||
{
|
{
|
||||||
for (int c=0; c < 5; c++)
|
for (int c=0; c < 5; c++)
|
||||||
{
|
{
|
||||||
buffer[c][0] = i+1;
|
buffer[c][0] = i+100;
|
||||||
}
|
}
|
||||||
buffer += 1;
|
buffer += 1;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ int test_buffer_multi_2()
|
|||||||
{
|
{
|
||||||
for (int c=0; c < 5; c++)
|
for (int c=0; c < 5; c++)
|
||||||
{
|
{
|
||||||
buffer[c][0] = i+1;
|
buffer[c][0] = i+100;
|
||||||
int v = buffer[c][-2];
|
int v = buffer[c][-2];
|
||||||
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ int test_buffer_multi_3()
|
|||||||
{
|
{
|
||||||
for (int c=0; c < 5; c++)
|
for (int c=0; c < 5; c++)
|
||||||
{
|
{
|
||||||
buffer[c][0] = i+1;
|
buffer[c][0] = i+100;
|
||||||
int v = buffer[c][-c];
|
int v = buffer[c][-c];
|
||||||
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
printf("c=%d: i=%d: v=%d\n", c, i, v);
|
||||||
}
|
}
|
||||||
@@ -108,8 +108,8 @@ int test_buffer_multi_4()
|
|||||||
dsp::BufferMulti<int>buffer(5, 10);
|
dsp::BufferMulti<int>buffer(5, 10);
|
||||||
printf("Buffer capacity = %zu\n", buffer.capacity());
|
printf("Buffer capacity = %zu\n", buffer.capacity());
|
||||||
|
|
||||||
dsp::Buffer<int> *mbv[5];
|
dsp::Buffer<int> *mbv[6];
|
||||||
for (int c=0; c < 5; c++)
|
for (int c=0; c <= 5; c++)
|
||||||
{
|
{
|
||||||
mbv[c] = new dsp::Buffer<int>(buffer[c], -c);
|
mbv[c] = new dsp::Buffer<int>(buffer[c], -c);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ int test_buffer_multi_4()
|
|||||||
{
|
{
|
||||||
for (int c=0; c < 5; c++)
|
for (int c=0; c < 5; c++)
|
||||||
{
|
{
|
||||||
buffer[c][0] = i+1;
|
buffer[c][0] = i+100;
|
||||||
}
|
}
|
||||||
buffer += 1;
|
buffer += 1;
|
||||||
}
|
}
|
||||||
@@ -126,10 +126,7 @@ int test_buffer_multi_4()
|
|||||||
buffer.reset();
|
buffer.reset();
|
||||||
for (int c=0; c < 5; c++)
|
for (int c=0; c < 5; c++)
|
||||||
{
|
{
|
||||||
for (int i=0; i < 10; i++)
|
print(*mbv[c], 10, "mbv[c]");
|
||||||
{
|
|
||||||
print(*mbv[c], 10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -145,21 +142,14 @@ int test_buffer_multi_5()
|
|||||||
|
|
||||||
for (int i=0; i < 10; i++)
|
for (int i=0; i < 10; i++)
|
||||||
{
|
{
|
||||||
buffer = i+1;
|
buffer = i+100;
|
||||||
buffer += 1;
|
buffer += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
print(buffer.buffer(), buffer.buffer().capacity());
|
|
||||||
|
|
||||||
|
|
||||||
for (int i=0; i < 10; i++)
|
for (int i=0; i < 10; i++)
|
||||||
{
|
{
|
||||||
print(buffer.quer(i), buffer.quer().capacity());
|
print(buffer.quer(i), buffer.quer().capacity(), "Title here 5");
|
||||||
// if (buffer.quer(0) == dsp::Buffer<int>(std::vector<int>{1,1,1,1,1}))
|
|
||||||
// {
|
|
||||||
// std::cout << "Okay" << std::endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -167,11 +157,9 @@ int test_buffer_multi_5()
|
|||||||
|
|
||||||
int test_buffer_multi()
|
int test_buffer_multi()
|
||||||
{
|
{
|
||||||
std::vector<int> v { 34,23 };
|
test_buffer_multi_1();
|
||||||
const std::vector<int> v2 { 34,23 };
|
test_buffer_multi_2();
|
||||||
// test_buffer_multi_1();
|
test_buffer_multi_3();
|
||||||
// test_buffer_multi_2();
|
|
||||||
// test_buffer_multi_3();
|
|
||||||
test_buffer_multi_4();
|
test_buffer_multi_4();
|
||||||
test_buffer_multi_5();
|
test_buffer_multi_5();
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ template<typename T>
|
|||||||
void print(const dsp::Buffer<T> &v, size_t size, std::string name=std::string(""))
|
void print(const dsp::Buffer<T> &v, size_t size, std::string name=std::string(""))
|
||||||
{
|
{
|
||||||
std::cout << "----------------------------------------------" << std::endl;
|
std::cout << "----------------------------------------------" << std::endl;
|
||||||
std::cout << "-" << name << std::endl;
|
std::cout << "- " << name << std::endl;
|
||||||
std::cout << "----------------------------------------------" << std::endl;
|
std::cout << "----------------------------------------------" << std::endl;
|
||||||
for(int i=0; i < size; i++)
|
for(int i=0; i < size; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ extern void test_buffer_multi();
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test_buffer();
|
test_buffer();
|
||||||
// test_buffer_multi();
|
test_buffer_multi();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user