stuff-from-scratch/test/core/TestDataStructures.cpp
2023-01-23 11:06:30 +00:00

37 lines
815 B
C++

#include "CircleBuffer.h"
#include "TestFramework.h"
#include <iostream>
TEST_CASE(TestCircleBuffer, "core")
{
CircleBuffer<unsigned> buffer(3);
for (auto item : {1, 2, 3})
{
//std::cout << "Add item: " << item << std::endl;
buffer.addItem(item);
}
for (std::size_t idx=0; idx<3; idx++)
{
auto item = buffer.getItem(idx);
//std::cout << "Got item: " << idx << " " << item << std::endl;
(void)item;
}
for (auto item : {4, 5})
{
//std::cout << "Add item: " << item << std::endl;
//buffer.addItem(item);
(void)item;
}
for (std::size_t idx=0; idx<3; idx++)
{
auto item = buffer.getItem(idx);
//std::cout << "Got item: " << idx << " " << item << std::endl;
(void)item;
}
}