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
path: root/base
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-05-25 18:32:24 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-05-27 14:17:13 +0300
commitd797fc0ff1e38c048d13652d9125ff7a97667ce6 (patch)
treeb1bae0f1e9587e1454ffc66b0d570183e8dd92c6 /base
parentbb46721ccdca16e94de33de872aa180a8ad741d4 (diff)
Unit tests on SortUnique and SortUnique with predicate.
Diffstat (limited to 'base')
-rw-r--r--base/base_tests/stl_helpers_test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/base/base_tests/stl_helpers_test.cpp b/base/base_tests/stl_helpers_test.cpp
index dddb028508..12130cc519 100644
--- a/base/base_tests/stl_helpers_test.cpp
+++ b/base/base_tests/stl_helpers_test.cpp
@@ -74,4 +74,31 @@ UNIT_TEST(EqualsBy)
TEST_EQUAL(expected[i], actual[i].Get(), ());
}
}
+
+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, ());
+}
+
+UNIT_TEST(SortUniquePred)
+{
+ struct Foo
+ {
+ int i, j;
+ };
+
+ vector<Foo> v = {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}};
+ my::SortUnique<Foo>([](Foo const & f1, Foo const & f2) { return f1.i < f2.i; }, v);
+
+ TEST_EQUAL(v.size(), 6, ());
+ TEST_EQUAL(v[0].i, 1, ());
+ TEST_EQUAL(v[1].i, 2, ());
+ TEST_EQUAL(v[2].i, 3, ());
+ TEST_EQUAL(v[3].i, 4, ());
+ TEST_EQUAL(v[4].i, 5, ());
+ TEST_EQUAL(v[5].i, 7, ());
+}
} // namespace