[indexer] similar languages changes.

This commit is contained in:
Arsentiy Milchakov 2018-02-21 16:02:30 +03:00 committed by Daria Volvenkova
parent ac89359d8f
commit c02c04f527
2 changed files with 42 additions and 11 deletions

View file

@ -28,8 +28,7 @@ int8_t GetIndex(string const & lang)
unordered_map<int8_t, vector<int8_t>> const kSimilarToDeviceLanguages =
{
{GetIndex("be"), {GetIndex("ru")}},
{GetIndex("ru"), {GetIndex("be")}}
{GetIndex("be"), {GetIndex("ru")}}
};
void GetMwmLangName(feature::RegionData const & regionData, StringUtf8Multilang const & src, string & out)

View file

@ -168,15 +168,15 @@ UNIT_TEST(GetPrefferedNames)
TEST_EQUAL(secondary, "", ());
}
{
int8_t deviceLang = StrUtf8::GetLangIndex("ru");
int8_t deviceLang = StrUtf8::GetLangIndex("be");
StrUtf8 src;
src.AddString("int_name", "int name");
src.AddString("en", "en name");
src.AddString("be", "be name");
src.AddString("ru", "ru name");
feature::GetPreferredNames(regionData, src, deviceLang, allowTranslit, primary, secondary);
TEST_EQUAL(primary, "be name", ());
TEST_EQUAL(primary, "ru name", ());
TEST_EQUAL(secondary, "int name", ());
}
{
@ -227,14 +227,14 @@ UNIT_TEST(GetPrefferedNames)
UNIT_TEST(GetPrefferedNamesLocal)
{
feature::RegionData regionData;
regionData.SetLanguages({"kk", "ru"});
int8_t deviceLang = StrUtf8::GetLangIndex("ru");
string primary, secondary;
bool const allowTranslit = true;
{
feature::RegionData regionData;
regionData.SetLanguages({"kk", "ru"});
int8_t deviceLang = StrUtf8::GetLangIndex("ru");
StrUtf8 src;
src.AddString("default", "default name");
src.AddString("en", "en name");
@ -245,7 +245,27 @@ UNIT_TEST(GetPrefferedNamesLocal)
TEST_EQUAL(secondary, "", ());
}
{
feature::RegionData regionData;
regionData.SetLanguages({"kk", "be"});
int8_t deviceLang = StrUtf8::GetLangIndex("be");
StrUtf8 src;
src.AddString("int_name", "int name");
src.AddString("en", "en name");
src.AddString("ru", "ru name");
feature::GetPreferredNames(regionData, src, deviceLang, allowTranslit, primary, secondary);
TEST_EQUAL(primary, "ru name", ());
TEST_EQUAL(secondary, "", ());
}
{
feature::RegionData regionData;
regionData.SetLanguages({"kk", "ru"});
int8_t deviceLang = StrUtf8::GetLangIndex("ru");
StrUtf8 src;
src.AddString("int_name", "int name");
src.AddString("en", "en name");
@ -253,7 +273,7 @@ UNIT_TEST(GetPrefferedNamesLocal)
feature::GetPreferredNames(regionData, src, deviceLang, allowTranslit, primary, secondary);
TEST_EQUAL(primary, "be name", ());
TEST_EQUAL(primary, "int name", ());
TEST_EQUAL(secondary, "", ());
}
}
@ -440,6 +460,18 @@ UNIT_TEST(GetReadableName)
TEST_EQUAL(name, "default name", ());
}
{
feature::RegionData regionData;
regionData.SetLanguages({"ru"});
int8_t deviceLang = StrUtf8::GetLangIndex("ru");
StrUtf8 src;
src.AddString("en", "en name");
src.AddString("be", "be name");
feature::GetReadableName(regionData, src, deviceLang, allowTranslit, name);
TEST_EQUAL(name, "en name", ());
}
}
UNIT_TEST(GetNameForSearchOnBooking)