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:
authorYury Melnichek <melnichek@gmail.com>2011-05-31 22:41:44 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:18:42 +0300
commitbf986ed042a265ebf98fee8d8b1c6cf6a51e1e25 (patch)
tree972e6fffca0741d81e01d6022e46903e823e8262 /search/search_tests
parent42a0ee08121005c6a244473756c6058705c71949 (diff)
[search] Add search::MatchLatLon().
Diffstat (limited to 'search/search_tests')
-rw-r--r--search/search_tests/latlon_match_test.cpp52
-rw-r--r--search/search_tests/search_tests.pro1
2 files changed, 53 insertions, 0 deletions
diff --git a/search/search_tests/latlon_match_test.cpp b/search/search_tests/latlon_match_test.cpp
new file mode 100644
index 0000000000..d001f6fc9b
--- /dev/null
+++ b/search/search_tests/latlon_match_test.cpp
@@ -0,0 +1,52 @@
+#include "../../testing/testing.hpp"
+#include "../latlon_match.hpp"
+#include "../../std/utility.hpp"
+
+namespace
+{
+
+pair<double, double> TestLatLonMatchSuccessful(string const & s)
+{
+ double lat = -3500;
+ double lon = -3500;
+ TEST(search::MatchLatLon(s, lat, lon), (s, lat, lon));
+ return make_pair(lat, lon);
+}
+
+void TestLatLonFailed(string const & s)
+{
+ double lat = -3500;
+ double lon = -3500;
+ TEST(!search::MatchLatLon(s, lat, lon), (s, lat, lon));
+ TEST_EQUAL(lat, -3500, ());
+ TEST_EQUAL(lon, -3500, ());
+}
+
+} // unnamed namespace
+
+UNIT_TEST(LatLonMatch)
+{
+ TestLatLonFailed("");
+ TestLatLonFailed("0.0");
+ TestLatLonFailed("2.0 sadas 2.0");
+ TestLatLonFailed("90.1 0.0");
+ TestLatLonFailed("-90.1 0.0");
+ TestLatLonFailed("0.0 361");
+ TestLatLonFailed("0.0 -181.0");
+
+ TEST_EQUAL(make_pair(2.0, 3.0), TestLatLonMatchSuccessful("2.0 3.0"), ());
+ TEST_EQUAL(make_pair(2.0, 3.0), TestLatLonMatchSuccessful("2.0, 3.0"), ());
+ TEST_EQUAL(make_pair(2.0, 3.0), TestLatLonMatchSuccessful("2.0;3.0"), ());
+ TEST_EQUAL(make_pair(2.0, 3.0), TestLatLonMatchSuccessful("2;3.0"), ());
+ TEST_EQUAL(make_pair(2.0, 3.03232424), TestLatLonMatchSuccessful("2.0;3.03232424"), ());
+ TEST_EQUAL(make_pair(2.0, 3.0), TestLatLonMatchSuccessful("2 3"), ());
+ TEST_EQUAL(make_pair(2.0, 3.0), TestLatLonMatchSuccessful("2 3."), ());
+ TEST_EQUAL(make_pair(2.0, 3.0), TestLatLonMatchSuccessful("(2.0, 3.0)"), ());
+ TEST_EQUAL(make_pair(0.0, 0.0), TestLatLonMatchSuccessful("0.0 0.0"), ());
+ TEST_EQUAL(make_pair(0.0, 180.0), TestLatLonMatchSuccessful("0.0 180"), ());
+ TEST_EQUAL(make_pair(0.0, -179.0), TestLatLonMatchSuccessful("0.0 181"), ());
+ TEST_EQUAL(make_pair(0.0, -170.0), TestLatLonMatchSuccessful("0.0 -170"), ());
+ TEST_EQUAL(make_pair(0.0, -180.0), TestLatLonMatchSuccessful("0.0 -180"), ());
+ TEST_EQUAL(make_pair(0.0, -160.0), TestLatLonMatchSuccessful("0.0 200"), ());
+ TEST_EQUAL(make_pair(0.0, 0.0), TestLatLonMatchSuccessful("0.0 360"), ());
+}
diff --git a/search/search_tests/search_tests.pro b/search/search_tests/search_tests.pro
index b5a30dd80f..67a61e8466 100644
--- a/search/search_tests/search_tests.pro
+++ b/search/search_tests/search_tests.pro
@@ -22,6 +22,7 @@ SOURCES += \
keyword_matcher_test.cpp \
query_test.cpp \
string_match_test.cpp \
+ latlon_match_test.cpp \
HEADERS += \
match_cost_mock.hpp \