Kylin/UnitTest/DataStructure/LinkedStackTest.cpp

40 lines
1.0 KiB
C++
Raw Permalink Normal View History

2023-12-27 10:29:16 +08:00
#include "LinkedStack.h"
#include <boost/test/unit_test.hpp>
using namespace Kylin;
class LinkedStackTest {
public:
LinkedStack<size_t> stack{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
};
BOOST_AUTO_TEST_SUITE(LinkedStackTestCase)
BOOST_FIXTURE_TEST_CASE(Push, LinkedStackTest) {
stack.push(123);
BOOST_CHECK_EQUAL(stack.size(), 11);
}
BOOST_FIXTURE_TEST_CASE(Pop, LinkedStackTest) {
BOOST_CHECK_EQUAL(stack.pop(), 9);
BOOST_CHECK_EQUAL(stack.size(), 9);
}
BOOST_FIXTURE_TEST_CASE(Top, LinkedStackTest) {
BOOST_CHECK_EQUAL(stack.top(), 9);
BOOST_CHECK_EQUAL(stack.size(), 10);
}
BOOST_FIXTURE_TEST_CASE(Size, LinkedStackTest) { BOOST_CHECK_EQUAL(stack.size(), 10); }
BOOST_FIXTURE_TEST_CASE(Clear, LinkedStackTest) {
stack.clear();
BOOST_CHECK_EQUAL(stack.size(), 0);
}
BOOST_FIXTURE_TEST_CASE(MoveConstructor, LinkedStackTest) {
auto stack2(std::move(stack));
BOOST_CHECK_EQUAL(stack.size(), 0);
BOOST_CHECK_EQUAL(stack2.size(), 10);
}
BOOST_AUTO_TEST_SUITE_END()