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

39 lines
1.0 KiB
C++

#include <boost/test/unit_test.hpp>
#include "StaticStack.h"
class StaticStackTest {
public:
Kylin::StaticStack<size_t, 10> stack;
StaticStackTest() {
for (size_t i = 0; i < 8; i++) {
stack.push(i);
}
}
};
BOOST_AUTO_TEST_SUITE(StaticStackTestCase)
BOOST_FIXTURE_TEST_CASE(Push, StaticStackTest) {
stack.push(8);
BOOST_CHECK_EQUAL(stack.size(), 9);
}
BOOST_FIXTURE_TEST_CASE(Pop, StaticStackTest) {
BOOST_CHECK_EQUAL(stack.pop(), 7);
BOOST_CHECK_EQUAL(stack.size(), 7);
}
BOOST_FIXTURE_TEST_CASE(Top, StaticStackTest) {
BOOST_CHECK_EQUAL(stack.top(), 7);
BOOST_CHECK_EQUAL(stack.size(), 8);
}
BOOST_FIXTURE_TEST_CASE(Size, StaticStackTest) { BOOST_CHECK_EQUAL(stack.size(), 8); }
BOOST_FIXTURE_TEST_CASE(Clear, StaticStackTest) {
stack.clear();
BOOST_CHECK_EQUAL(stack.size(), 0);
}
BOOST_FIXTURE_TEST_CASE(Capacity, StaticStackTest) { BOOST_CHECK_EQUAL(stack.capacity(), 10); }
BOOST_AUTO_TEST_SUITE_END()