Skip to content

Commit

Permalink
add czech people names (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal authored Nov 13, 2023
1 parent 1b6aa99 commit 870280c
Show file tree
Hide file tree
Showing 8 changed files with 541 additions and 13 deletions.
11 changes: 6 additions & 5 deletions include/faker-cxx/types/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ enum class Language
Nepali,
Spanish,
Turkish,
Czech,
};

const std::vector<Language> languages{
Language::English, Language::Polish, Language::Italian, Language::French, Language::German, Language::Russian,
Language::Romanian, Language::Hindi, Language::Finnish, Language::Nepali, Language::Spanish, Language::Turkish
};
const std::vector<Language> languages{Language::English, Language::Polish, Language::Italian, Language::French,
Language::German, Language::Russian, Language::Romanian, Language::Hindi,
Language::Finnish, Language::Nepali, Language::Spanish, Language::Turkish,
Language::Czech};

inline std::string toString(Language language)
{
Expand All @@ -33,7 +34,7 @@ inline std::string toString(Language language)
{Language::French, "French"}, {Language::German, "German"}, {Language::Russian, "Russian"},
{Language::Romanian, "Romanian"}, {Language::Hindi, "Hindi"}, {Language::Finnish, "Finnish"},
{Language::Nepali, "Nepali"}, {Language::Spanish, "Spanish"}, {Language::Turkish, "Turkish"},
};
{Language::Czech, "Czech"}};

return languageToStringMapping.at(language);
}
Expand Down
6 changes: 4 additions & 2 deletions src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <set>

#include "../../common/StringHelper.h"
#include "data/czech/CzechPeopleNames.h"
#include "data/english/EnglishPeopleNames.h"
#include "data/finnish/FinnishPeopleNames.h"
#include "data/french/FrenchPeopleNames.h"
Expand All @@ -20,9 +21,9 @@
#include "data/russian/RussianPeopleNames.h"
#include "data/spanish/SpanishPeopleNames.h"
#include "data/turkish/TurkishPeopleNames.h"
#include "data/ZodiacSigns.h"
#include "faker-cxx/Helper.h"
#include "fmt/format.h"
#include "data/ZodiacSigns.h"

namespace faker
{
Expand All @@ -37,6 +38,7 @@ const std::map<Language, PeopleNames> languageToPeopleNamesMapping{
{Language::Romanian, romanianPeopleNames}, {Language::Hindi, indianPeopleNames},
{Language::Finnish, finnishPeopleNames}, {Language::Nepali, nepalesePeopleNames},
{Language::Spanish, spanishPeopleNames}, {Language::Turkish, turkishPeopleNames},
{Language::Czech, czechPeopleNames},
};

std::string middleNameForLanguage(Language language, std::optional<Sex> sex);
Expand Down Expand Up @@ -407,4 +409,4 @@ std::string Person::chineseZodiac()
{
return Helper::arrayElement<std::string>(chineseZodiacs);
}
}
}
13 changes: 7 additions & 6 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "gtest/gtest.h"

#include "../../common/StringHelper.h"
#include "data/czech/CzechPeopleNames.h"
#include "data/english/EnglishPeopleNames.h"
#include "data/finnish/FinnishPeopleNames.h"
#include "data/french/FrenchPeopleNames.h"
Expand All @@ -15,13 +16,13 @@
#include "data/italian/ItalianPeopleNames.h"
#include "data/JobTitles.h"
#include "data/Nationalities.h"
#include "data/ZodiacSigns.h"
#include "data/nepalese/NepalesePeopleNames.h"
#include "data/polish/PolishPeopleNames.h"
#include "data/romanian/RomanianPeopleNames.h"
#include "data/russian/RussianPeopleNames.h"
#include "data/spanish/SpanishPeopleNames.h"
#include "data/turkish/TurkishPeopleNames.h"
#include "data/ZodiacSigns.h"
#include "src/modules/person/data/PeopleNames.h"

using namespace ::testing;
Expand All @@ -38,7 +39,7 @@ const std::map<Language, PeopleNames> languageToPeopleNamesMapping{
{Language::Romanian, romanianPeopleNames}, {Language::Hindi, indianPeopleNames},
{Language::Finnish, finnishPeopleNames}, {Language::Nepali, nepalesePeopleNames},
{Language::Spanish, spanishPeopleNames}, {Language::Turkish, turkishPeopleNames},
};
{Language::Czech, czechPeopleNames}};

const std::map<Language, std::string> generatedTestName{
{Language::English, "shouldGenerateEnglishName"}, {Language::French, "shouldGenerateFrenchName"},
Expand All @@ -47,6 +48,7 @@ const std::map<Language, std::string> generatedTestName{
{Language::Romanian, "shouldGenerateRomanianName"}, {Language::Hindi, "shouldGenerateIndianName"},
{Language::Finnish, "shouldGenerateFinnishName"}, {Language::Nepali, "shouldGenerateNepaleseName"},
{Language::Spanish, "shouldGenerateSpanishName"}, {Language::Turkish, "shouldGenerateTurkishName"},
{Language::Czech, "shouldGenerateCzechName"},
};
}

Expand Down Expand Up @@ -390,14 +392,13 @@ TEST_F(PersonTest, shouldGenerateWesternZodiacs)
const auto generatedWesternZodiacs = Person::westernZodiac();

ASSERT_TRUE(std::ranges::any_of(westernZodiacs, [generatedWesternZodiacs](const std::string& westernZodiac)
{ return generatedWesternZodiacs == westernZodiac;}));

{ return generatedWesternZodiacs == westernZodiac; }));
}

TEST_F(PersonTest, shouldGenerateChineseZodiacs)
{
const auto generatedChineseZodiacs = Person::chineseZodiac();

ASSERT_TRUE(std::ranges::any_of(chineseZodiacs, [generatedChineseZodiacs](const std::string& chineseZodiac)
{ return generatedChineseZodiacs == chineseZodiac;}));
}
{ return generatedChineseZodiacs == chineseZodiac; }));
}
Loading

0 comments on commit 870280c

Please sign in to comment.