diff options
author | Maxim Pimenov <m@maps.me> | 2016-06-16 02:16:00 +0300 |
---|---|---|
committer | Maxim Pimenov <m@maps.me> | 2016-06-16 11:57:40 +0300 |
commit | 613be5aacd6ea5e6aafb34dda93070965554dbb8 (patch) | |
tree | 00036d5e412676d6b51ee3518b0cab885f239594 /search | |
parent | 24c3b7857b8992282342fb7a020e59be0b589e0b (diff) |
Review fixes.
Diffstat (limited to 'search')
-rw-r--r-- | search/geocoder.cpp | 3 | ||||
-rw-r--r-- | search/search_integration_tests/processor_test.cpp | 48 | ||||
-rw-r--r-- | search/search_tests/house_numbers_matcher_test.cpp | 4 |
3 files changed, 54 insertions, 1 deletions
diff --git a/search/geocoder.cpp b/search/geocoder.cpp index e9749e69ce..1f0ac2b8fa 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -1095,7 +1095,8 @@ void Geocoder::GreedilyMatchStreets() if (IsStreetSynonymPrefix(token)) continue; - if (house_numbers::LooksLikeHouseNumber(token, true /* isPrefix */)) + bool const isPrefix = curToken >= m_params.m_tokens.size(); + if (house_numbers::LooksLikeHouseNumber(token, isPrefix)) { CreateStreetsLayerAndMatchLowerLayers(startToken, curToken, allFeatures); lastStopToken = curToken; diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 6676b73a89..89c9032634 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -366,6 +366,54 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo) } } +UNIT_CLASS_TEST(ProcessorTest, TestHouseNumbers) +{ + string const countryName = "HouseNumberLand"; + + TestCity greenCity(m2::PointD(0, 0), "Зеленоград", "ru", 100 /* rank */); + + TestStreet street( + vector<m2::PointD>{m2::PointD(0.0, -10.0), m2::PointD(0, 0), m2::PointD(5.0, 5.0)}, + "Генерала Генералова", "ru"); + + TestBuilding building0(m2::PointD(2.0, 2.0), "", "100", "en"); + TestBuilding building1(m2::PointD(3.0, 3.0), "", "к200", "ru"); + TestBuilding building2(m2::PointD(4.0, 4.0), "", "300 строение 400", "ru"); + + BuildWorld([&](TestMwmBuilder & builder) { builder.Add(greenCity); }); + auto countryId = BuildCountry(countryName, [&](TestMwmBuilder & builder) { + builder.Add(street); + builder.Add(building0); + builder.Add(building1); + builder.Add(building2); + }); + + { + TRules rules{ExactMatch(countryId, building0)}; + TEST(ResultsMatch("Зеленоград генералова к100", "ru", rules), ()); + } + { + TRules rules{ExactMatch(countryId, building1)}; + TEST(ResultsMatch("Зеленоград генералова к200", "ru", rules), ()); + } + { + TRules rules{ExactMatch(countryId, building1)}; + TEST(ResultsMatch("Зеленоград к200 генералова", "ru", rules), ()); + } + { + TRules rules{ExactMatch(countryId, building2)}; + TEST(ResultsMatch("Зеленоград 300 строение 400 генералова", "ru", rules), ()); + } + { + TRules rules{}; + TEST(ResultsMatch("Зеленоград генералова строе 300", "ru", rules), ()); + } + { + TRules rules{ExactMatch(countryId, building2)}; + TEST(ResultsMatch("Зеленоград генералова 300 строе", "ru", rules), ()); + } +} + UNIT_CLASS_TEST(ProcessorTest, TestPostcodes) { string const countryName = "Russia"; diff --git a/search/search_tests/house_numbers_matcher_test.cpp b/search/search_tests/house_numbers_matcher_test.cpp index d5540e6fe5..dad6538098 100644 --- a/search/search_tests/house_numbers_matcher_test.cpp +++ b/search/search_tests/house_numbers_matcher_test.cpp @@ -157,6 +157,10 @@ UNIT_TEST(LooksLikeHouseNumber_Smoke) TEST(LooksLikeHouseNumber("39 строе", true /* isPrefix */), ()); TEST(!LooksLikeHouseNumber("39 строе", false /* isPrefix */), ()); + TEST(LooksLikeHouseNumber("39", true /* isPrefix */), ()); + TEST(LooksLikeHouseNumber("39", false /* isPrefix */), ()); + TEST(LooksLikeHouseNumber("строе", true /* isPrefix */), ()); + TEST(!LooksLikeHouseNumber("строе", false /* isPrefix */), ()); TEST(LooksLikeHouseNumber("дом ", true /* isPrefix */), ()); TEST(LooksLikeHouseNumber("дом ", false /* isPrefix */), ()); |