Kylin/UnitTest/DataStructure/StaticQueueTest.cpp
2023-12-27 10:29:16 +08:00

37 lines
1013 B
C++

#include "StaticQueue.h"
#include <boost/test/unit_test.hpp>
using namespace Kylin;
class StaticQueueTest {
public:
StaticQueue<size_t, 10> queue;
StaticQueueTest() {
for (size_t i = 0; i < 8; i++) {
queue.enqueue(i);
}
}
};
BOOST_AUTO_TEST_SUITE(StaticQueueTestCase)
BOOST_FIXTURE_TEST_CASE(Size, StaticQueueTest) { BOOST_CHECK_EQUAL(queue.size(), 8); }
BOOST_FIXTURE_TEST_CASE(Capacity, StaticQueueTest) { BOOST_CHECK_EQUAL(queue.capacity(), 10); }
BOOST_FIXTURE_TEST_CASE(Head, StaticQueueTest) { BOOST_CHECK_EQUAL(queue.head(), 0); }
BOOST_FIXTURE_TEST_CASE(Enqueue, StaticQueueTest) {
queue.enqueue(8);
BOOST_CHECK_EQUAL(queue.size(), 9);
}
BOOST_FIXTURE_TEST_CASE(Dequeue, StaticQueueTest) {
BOOST_CHECK_EQUAL(queue.dequeue(), 0);
BOOST_CHECK_EQUAL(queue.size(), 7);
}
BOOST_FIXTURE_TEST_CASE(Clear, StaticQueueTest) {
queue.clear();
BOOST_CHECK_EQUAL(queue.size(), 0);
}
BOOST_AUTO_TEST_SUITE_END()