Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'base/base_tests/stl_helpers_test.cpp')
-rw-r--r--base/base_tests/stl_helpers_test.cpp64
1 files changed, 30 insertions, 34 deletions
diff --git a/base/base_tests/stl_helpers_test.cpp b/base/base_tests/stl_helpers_test.cpp
index ac60b8c064..f42e8ac4df 100644
--- a/base/base_tests/stl_helpers_test.cpp
+++ b/base/base_tests/stl_helpers_test.cpp
@@ -77,41 +77,37 @@ UNIT_TEST(EqualsBy)
UNIT_TEST(SortUnique)
{
- vector<int> v = {1, 2, 1, 4, 3, 5, 2, 7, 1};
- my::SortUnique(v);
- vector<int> const expected = {1, 2, 3, 4, 5, 7};
- TEST_EQUAL(v, expected, ());
-}
+ {
+ vector<int> v = {1, 2, 1, 4, 3, 5, 2, 7, 1};
+ my::SortUnique(v);
+ vector<int> const expected = {1, 2, 3, 4, 5, 7};
+ TEST_EQUAL(v, expected, ());
+ }
+ {
+ using TValue = int;
+ using TPair = pair<TValue, int>;
+ vector<TPair> v =
+ {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}};
-UNIT_TEST(SortUniqueCompPredTest1)
-{
- using TValue = int;
- using TPair = pair<TValue, int>;
- vector<TPair> v =
- {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}};
-
- my::SortUnique<TPair>(v, my::CompareBy(&TPair::first),
- [](TPair const & p1, TPair const & p2) { return p1.first == p2.first; });
-
- vector<TValue> const expected = {1, 2, 3, 4, 5, 7};
- TEST_EQUAL(v.size(), expected.size(), ());
- for (int i = 0; i < v.size(); ++i)
- TEST_EQUAL(v[i].first, expected[i], (i));
-}
+ my::SortUnique<TPair>(v, my::LessBy(&TPair::first), my::EqualsBy(&TPair::first));
-UNIT_TEST(SortUniqueCompPredTest2)
-{
- using TValue = double;
- using TPair = pair<TValue, int>;
- vector<TPair> v =
- {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}};
-
- my::SortUnique<TPair>(v, my::CompareBy(&TPair::first),
- [](TPair const & p1, TPair const & p2) { return p1.first == p2.first; });
-
- vector<TValue> const expected = {0.5, 1000.99, 1234.56789};
- TEST_EQUAL(v.size(), expected.size(), ());
- for (int i = 0; i < v.size(); ++i)
- TEST_EQUAL(v[i].first, expected[i], (i));
+ vector<TValue> const expected = {1, 2, 3, 4, 5, 7};
+ TEST_EQUAL(v.size(), expected.size(), ());
+ for (int i = 0; i < v.size(); ++i)
+ TEST_EQUAL(v[i].first, expected[i], (i));
+ }
+ {
+ using TValue = double;
+ using TPair = pair<TValue, int>;
+ vector<TPair> v =
+ {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}};
+
+ my::SortUnique<TPair>(v, my::LessBy(&TPair::first), my::EqualsBy(&TPair::first));
+
+ vector<TValue> const expected = {0.5, 1000.99, 1234.56789};
+ TEST_EQUAL(v.size(), expected.size(), ());
+ for (int i = 0; i < v.size(); ++i)
+ TEST_EQUAL(v[i].first, expected[i], (i));
+ }
}
} // namespace