Skip to content

Commit

Permalink
test: person module test cases updated
Browse files Browse the repository at this point in the history
* removed unnecessary test functions and test suites

Signed-off-by: Guru Mehar Rachaputi <[email protected]>
  • Loading branch information
00thirdeye00 committed Aug 28, 2024
1 parent 8d3a82f commit 49892bf
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions tests/modules/person_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,6 @@ const struct PeopleNames& getPeopleNamesByLocale(Locale locale)
}
}

std::string_view translateSex(Sex sex, Locale locale = Locale::en_US)
{
auto sexTranslation = sexTranslations.find(locale);

if (sexTranslation == sexTranslations.end()){
sexTranslation = sexTranslations.find(Locale::en_US);
}

return sexTranslation->second.at(sex);
}

}

bool checkTokenFormat(const std::string& bio);
Expand Down Expand Up @@ -554,67 +543,6 @@ TEST_F(PersonTest, shouldGenerateChineseZodiacs)
{ return generatedChineseZodiacs == chineseZodiac; }));
}

class PersonSexSuite : public TestWithParam<std::pair<Locale, Sex>>
{
};

TEST_P(PersonSexSuite, shouldTranslateSexCorrectly)
{
const auto locale = GetParam().first;
const auto sex = GetParam().second;

auto expectedTranslation = sexTranslations.find(locale);

if (expectedTranslation == sexTranslations.end())
{
expectedTranslation = sexTranslations.find(Locale::en_US);
}

const auto actualTranslation = translateSex(sex, locale);

ASSERT_TRUE(expectedTranslation->second.at(sex) == actualTranslation);
}

std::vector<std::pair<Locale, Sex>> languageSexPairs = {
{Locale::en_US, Sex::Male}, {Locale::en_US, Sex::Female}, {Locale::pl_PL, Sex::Male},
{Locale::pl_PL, Sex::Female}, {Locale::it_IT, Sex::Male}, {Locale::it_IT, Sex::Female},
{Locale::fr_FR, Sex::Male}, {Locale::fr_FR, Sex::Female}, {Locale::de_DE, Sex::Male},
{Locale::de_DE, Sex::Female}, {Locale::ru_RU, Sex::Male}, {Locale::ru_RU, Sex::Female},
{Locale::ro_RO, Sex::Male}, {Locale::ro_RO, Sex::Female}, {Locale::hi_IN, Sex::Male},
{Locale::hi_IN, Sex::Female}, {Locale::fi_FI, Sex::Male}, {Locale::fi_FI, Sex::Female},
{Locale::ne_NP, Sex::Male}, {Locale::ne_NP, Sex::Female}, {Locale::es_ES, Sex::Male},
{Locale::es_ES, Sex::Female}, {Locale::tr_TR, Sex::Male}, {Locale::tr_TR, Sex::Female},
{Locale::cs_CZ, Sex::Male}, {Locale::cs_CZ, Sex::Female}, {Locale::sk_SK, Sex::Male},
{Locale::sk_SK, Sex::Female}, {Locale::uk_UA, Sex::Male}, {Locale::uk_UA, Sex::Female},
{Locale::da_DK, Sex::Male}, {Locale::da_DK, Sex::Female}, {Locale::sv_SE, Sex::Male},
{Locale::sv_SE, Sex::Female}, {Locale::pt_PT, Sex::Male}, {Locale::pt_PT, Sex::Female},
{Locale::nn_NO, Sex::Male}, {Locale::nn_NO, Sex::Female}, {Locale::ja_JP, Sex::Male},
{Locale::ja_JP, Sex::Female}, {Locale::hu_HU, Sex::Male}, {Locale::hu_HU, Sex::Female},
{Locale::hr_HR, Sex::Male}, {Locale::hr_HR, Sex::Female}, {Locale::el_GR, Sex::Male},
{Locale::el_GR, Sex::Female}, {Locale::sl_SI, Sex::Male}, {Locale::sl_SI, Sex::Female},
{Locale::nl_NL, Sex::Male}, {Locale::nl_NL, Sex::Female}, {Locale::zh_CN, Sex::Male},
{Locale::zh_CN, Sex::Female}, {Locale::ko_KR, Sex::Male}, {Locale::ko_KR, Sex::Female},
{Locale::sr_RS, Sex::Male}, {Locale::sr_RS, Sex::Female}, {Locale::mk_MK, Sex::Male},
{Locale::mk_MK, Sex::Female}, {Locale::sq_AL, Sex::Male}, {Locale::sq_AL, Sex::Female},
{Locale::lv_LV, Sex::Male}, {Locale::lv_LV, Sex::Female}, {Locale::ga_IE, Sex::Male},
{Locale::ga_IE, Sex::Female}, {Locale::be_BY, Sex::Male}, {Locale::be_BY, Sex::Female},
{Locale::et_EE, Sex::Male}, {Locale::et_EE, Sex::Female}};

std::string toString(Sex sex, Locale locale = Locale::en_US)
{
auto sexTranslation = sexTranslations.find(locale);

if(sexTranslation == sexTranslations.end()){
sexTranslation = sexTranslations.find(Locale::en_US);
}

return std::string{sexTranslation->second.at(sex)};
}

INSTANTIATE_TEST_SUITE_P(TestPersonSexTranslation, PersonSexSuite, testing::ValuesIn(languageSexPairs),
[](const testing::TestParamInfo<PersonSexSuite::ParamType>& paramInfo)
{ return toString(paramInfo.param.first) + "_" + toString(paramInfo.param.second); });

const std::unordered_map<Locale, unsigned> ssnLengths{
{Locale::pl_PL, 11}, {Locale::es_US, 11}, {Locale::en_US, 11}, {Locale::en_GB, 13}, {Locale::de_DE, 12},
{Locale::fr_FR, 19}, {Locale::it_IT, 19}, {Locale::es_ES, 10}, {Locale::ca_ES, 10}, {Locale::as_IN, 10},
Expand Down

0 comments on commit 49892bf

Please sign in to comment.