stuff-from-scratch/test/core/TestDataStructures.cpp

38 lines
805 B
C++
Raw Normal View History

2022-11-24 09:05:39 +00:00
#include "CircleBuffer.h"
2022-11-29 18:00:19 +00:00
#include "TestFramework.h"
2022-11-24 09:05:39 +00:00
#include <iostream>
2022-11-29 18:00:19 +00:00
TEST_CASE(TestCircleBuffer, "core")
2022-11-24 09:05:39 +00:00
{
CircleBuffer<unsigned> buffer(3);
for (auto item : {1, 2, 3})
{
2022-11-30 18:28:50 +00:00
//std::cout << "Add item: " << item << std::endl;
2022-11-24 09:05:39 +00:00
buffer.addItem(item);
}
2023-12-27 12:20:02 +00:00
for (size_t idx=0; idx<3; idx++)
2022-11-24 09:05:39 +00:00
{
auto item = buffer.getItem(idx);
2022-11-30 18:28:50 +00:00
//std::cout << "Got item: " << idx << " " << item << std::endl;
2023-01-23 11:06:30 +00:00
(void)item;
2022-11-24 09:05:39 +00:00
}
for (auto item : {4, 5})
{
2022-11-30 18:28:50 +00:00
//std::cout << "Add item: " << item << std::endl;
//buffer.addItem(item);
2023-01-23 11:06:30 +00:00
(void)item;
2022-11-24 09:05:39 +00:00
}
2023-12-27 12:20:02 +00:00
for (size_t idx=0; idx<3; idx++)
2022-11-24 09:05:39 +00:00
{
auto item = buffer.getItem(idx);
2022-11-30 18:28:50 +00:00
//std::cout << "Got item: " << idx << " " << item << std::endl;
2023-01-23 11:06:30 +00:00
(void)item;
2022-11-24 09:05:39 +00:00
}
}