forked from organicmaps/organicmaps
[search] Fixed features matcher.
This commit is contained in:
parent
b1041c1ecd
commit
d15ab6b24e
3 changed files with 66 additions and 5 deletions
|
@ -21,6 +21,8 @@ public:
|
|||
// SyncWithDisk() is called.
|
||||
LocalCountryFile(string const & directory, CountryFile const & countryFile, int64_t version);
|
||||
|
||||
virtual ~LocalCountryFile() = default;
|
||||
|
||||
// Syncs internal state like availability of map and routing files,
|
||||
// their sizes etc. with disk.
|
||||
void SyncWithDisk();
|
||||
|
|
|
@ -111,7 +111,7 @@ void FullMatchInTrie(TrieIterator const & trieRoot,
|
|||
unique_ptr<search::TrieIterator> const pIter(
|
||||
MoveTrieIteratorToString(trieRoot, s, symbolsMatched, bFullEdgeMatched));
|
||||
|
||||
if (!pIter || !bFullEdgeMatched || symbolsMatched != s.size())
|
||||
if (!pIter || (s.size() != 0 && !bFullEdgeMatched) || symbolsMatched != s.size())
|
||||
return;
|
||||
|
||||
#if defined(OMIM_OS_IPHONE) && !defined(__clang__)
|
||||
|
|
|
@ -10,8 +10,28 @@
|
|||
#include "platform/country_defines.hpp"
|
||||
#include "platform/country_file.hpp"
|
||||
#include "platform/local_country_file.hpp"
|
||||
#include "platform/local_country_file_utils.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
class ScopedMapFile : public platform::LocalCountryFile
|
||||
{
|
||||
public:
|
||||
ScopedMapFile(string const & name)
|
||||
: platform::LocalCountryFile(GetPlatform().TmpDir(), platform::CountryFile(name), 0)
|
||||
{
|
||||
platform::CountryIndexes::DeleteFromDisk(*this);
|
||||
}
|
||||
|
||||
~ScopedMapFile() override
|
||||
{
|
||||
platform::CountryIndexes::DeleteFromDisk(*this);
|
||||
DeleteFromDisk(TMapOptions::EMap);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void TestFeaturesCount(TestSearchEngine const & engine, m2::RectD const & rect,
|
||||
size_t expectedCount)
|
||||
{
|
||||
|
@ -27,8 +47,7 @@ void TestFeaturesCount(TestSearchEngine const & engine, m2::RectD const & rect,
|
|||
UNIT_TEST(GenerateTestMwm_Smoke)
|
||||
{
|
||||
classificator::Load();
|
||||
|
||||
platform::LocalCountryFile file(GetPlatform().TmpDir(), platform::CountryFile("BuzzCity"), 0);
|
||||
ScopedMapFile file("BuzzTown");
|
||||
{
|
||||
TestMwmBuilder builder(file);
|
||||
builder.AddPOI(m2::PointD(0, 0), "Wine shop", "en");
|
||||
|
@ -59,6 +78,46 @@ UNIT_TEST(GenerateTestMwm_Smoke)
|
|||
request.Wait();
|
||||
TEST_EQUAL(4, request.Results().size(), ());
|
||||
}
|
||||
|
||||
file.DeleteFromDisk(TMapOptions::EMap);
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateTestMwm_NotPrefixFreeNames)
|
||||
{
|
||||
classificator::Load();
|
||||
ScopedMapFile file("ATown");
|
||||
{
|
||||
TestMwmBuilder builder(file);
|
||||
builder.AddPOI(m2::PointD(0, 0), "a", "en");
|
||||
builder.AddPOI(m2::PointD(0, 1), "aa", "en");
|
||||
builder.AddPOI(m2::PointD(1, 1), "aa", "en");
|
||||
builder.AddPOI(m2::PointD(1, 0), "aaa", "en");
|
||||
builder.AddPOI(m2::PointD(2, 0), "aaa", "en");
|
||||
builder.AddPOI(m2::PointD(2, 1), "aaa", "en");
|
||||
}
|
||||
TEST_EQUAL(TMapOptions::EMap, file.GetFiles(), ());
|
||||
|
||||
TestSearchEngine engine("en" /* locale */);
|
||||
auto ret = engine.RegisterMap(file);
|
||||
TEST_EQUAL(MwmSet::RegResult::Success, ret.second, ("Can't register generated map."));
|
||||
TEST(ret.first.IsAlive(), ("Can't get lock on a generated map."));
|
||||
|
||||
TestFeaturesCount(engine, m2::RectD(m2::PointD(0, 0), m2::PointD(2, 2)), 6);
|
||||
|
||||
{
|
||||
TestSearchRequest request(engine, "a ", "en",
|
||||
m2::RectD(m2::PointD(0, 0), m2::PointD(100, 100)));
|
||||
request.Wait();
|
||||
TEST_EQUAL(1, request.Results().size(), ());
|
||||
}
|
||||
{
|
||||
TestSearchRequest request(engine, "aa ", "en",
|
||||
m2::RectD(m2::PointD(0, 0), m2::PointD(100, 100)));
|
||||
request.Wait();
|
||||
TEST_EQUAL(2, request.Results().size(), ());
|
||||
}
|
||||
{
|
||||
TestSearchRequest request(engine, "aaa ", "en",
|
||||
m2::RectD(m2::PointD(0, 0), m2::PointD(100, 100)));
|
||||
request.Wait();
|
||||
TEST_EQUAL(3, request.Results().size(), ());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue