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

69 lines
1.6 KiB
C++

#include "Sort.h"
#include "DynamicArray.h"
#include "SharedPointer.h"
#include <boost/test/unit_test.hpp>
using namespace Kylin;
class SortTest {
public:
size_t unsort[10] = {84, 102, 5, 60, 78, 14, 66, 60, 11, 86};
size_t sort[10] = {5, 11, 14, 60, 60, 66, 78, 84, 86, 102};
};
BOOST_FIXTURE_TEST_CASE(Select, SortTest) {
Sort::select(unsort, 10);
for (size_t i = 0; i < 10; i++) {
BOOST_CHECK_EQUAL(unsort[i], sort[i]);
}
}
BOOST_FIXTURE_TEST_CASE(Insert, SortTest) {
Sort::insert(unsort, 10);
for (size_t i = 0; i < 10; i++) {
BOOST_CHECK_EQUAL(unsort[i], sort[i]);
}
}
BOOST_FIXTURE_TEST_CASE(Bubble, SortTest) {
Sort::bubble(unsort, 10);
for (size_t i = 0; i < 10; i++) {
BOOST_CHECK_EQUAL(unsort[i], sort[i]);
}
}
BOOST_FIXTURE_TEST_CASE(Shell, SortTest) {
Sort::shell(unsort, 10);
for (size_t i = 0; i < 10; i++) {
BOOST_CHECK_EQUAL(unsort[i], sort[i]);
}
}
BOOST_FIXTURE_TEST_CASE(Quick, SortTest) {
Sort::quick(unsort, 10);
for (size_t i = 0; i < 10; i++) {
BOOST_CHECK_EQUAL(unsort[i], sort[i]);
}
}
BOOST_FIXTURE_TEST_CASE(Merge, SortTest) {
Sort::merge(unsort, 10);
for (size_t i = 0; i < 10; i++) {
BOOST_CHECK_EQUAL(unsort[i], sort[i]);
}
}
// class Data{
// public:
// size_t id;
// double data1[1000];
// size_t data2[1000];
// float data3[1000];
//};
// TEST(Sort,large_data) {
//// Data data[1000];
//// for(size_t i=0;i<1000;i++) data[i].id = i;
//}