| 24 | |
| 25 | template <template <typename...> class Cont> |
| 26 | void TestSortUnique() |
| 27 | { |
| 28 | { |
| 29 | Cont<int> actual = {1, 2, 1, 4, 3, 5, 2, 7, 1}; |
| 30 | SortUnique(actual); |
| 31 | Cont<int> const expected = {1, 2, 3, 4, 5, 7}; |
| 32 | TEST_EQUAL(actual, expected, ()); |
| 33 | } |
| 34 | { |
| 35 | using Value = int; |
| 36 | using Pair = std::pair<Value, int>; |
| 37 | Cont<Pair> d = {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}}; |
| 38 | |
| 39 | SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first)); |
| 40 | |
| 41 | Cont<Value> const expected = {1, 2, 3, 4, 5, 7}; |
| 42 | TEST_EQUAL(d.size(), expected.size(), ()); |
| 43 | for (size_t i = 0; i < d.size(); ++i) |
| 44 | TEST_EQUAL(d[i].first, expected[i], (i)); |
| 45 | } |
| 46 | { |
| 47 | using Value = double; |
| 48 | using Pair = std::pair<Value, int>; |
| 49 | Cont<Pair> d = {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}}; |
| 50 | |
| 51 | SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first)); |
| 52 | |
| 53 | Cont<Value> const expected = {0.5, 1000.99, 1234.56789}; |
| 54 | TEST_EQUAL(d.size(), expected.size(), ()); |
| 55 | for (size_t i = 0; i < d.size(); ++i) |
| 56 | TEST_EQUAL(d[i].first, expected[i], (i)); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | template <template <typename...> class Cont> |
| 61 | void TestEqualsBy() |
nothing calls this directly
no test coverage detected