-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort_unittests.cpp
39 lines (30 loc) · 1.01 KB
/
sort_unittests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "sort.h"
#include "gtest/gtest.h"
#include<vector>
namespace
{
TEST(Sort, CountSort)
{
std::vector<int> vectorToSort {6, 3, 1, 3, 2, 4, 0, 1,10,0};
const std::vector<int> expectedSort {0,0, 1, 1, 2, 3, 3, 4, 6,10};
const int biggestIntOnVector = 10;
CountSort(vectorToSort, biggestIntOnVector);
EXPECT_EQ(expectedSort, vectorToSort);
}
TEST(Sort, RadixSortVector)
{
std::vector<int> vectorToSort {13, 5, 1, 16, 24, 21, 10, 84, 0, 16};
const std::vector<int> expectedSort {0, 1, 5, 10, 13, 16, 16, 21, 24, 84};
const int biggestIntOnVector = 84;
RadixSortVector(vectorToSort, biggestIntOnVector);
EXPECT_EQ(expectedSort, vectorToSort);
}
TEST(Sort, RadixSortList)
{
std::list<int> listToSort {13, 5, 1, 16, 24, 21, 10, 84, 0, 16};
const std::list<int> expectedSort {0, 1, 5, 10, 13, 16, 16, 21, 24, 84};
const int biggestIntOnList = 84;
RadixSortList(listToSort, biggestIntOnList);
EXPECT_EQ(expectedSort, listToSort);
}
} // namespace