stuff-from-scratch/test/core/TestDataStructures.cpp
2022-11-24 09:05:39 +00:00

34 lines
707 B
C++

#include "CircleBuffer.h"
#include <iostream>
int main()
{
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;
}
for (auto item : {4, 5})
{
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;
}
return 0;
}