Skip to content

Commit

Permalink
add bulgarian names
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal committed Dec 31, 2023
1 parent 5def024 commit 077f86e
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 96 deletions.
8 changes: 5 additions & 3 deletions include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum class Country
Belarus,
Estonia,
Iran,
Bulgaria,
};

const std::vector<Country> countries{
Expand All @@ -62,8 +63,8 @@ const std::vector<Country> countries{
Country::Japan, Country::Portugal, Country::Hungary, Country::Croatia, Country::Greece,
Country::Slovenia, Country::Austria, Country::Switzerland, Country::Belgium, Country::Netherlands,
Country::China, Country::Korea, Country::Canada, Country::Mexico, Country::Argentina,
Country::Australia, Country::Serbia, Country::Macedonia, Country::Albania, Country::Latvia, Country::Ireland,
Country::Belarus, Country::Estonia,Country::Iran,
Country::Australia, Country::Serbia, Country::Macedonia, Country::Albania, Country::Latvia,
Country::Ireland, Country::Belarus, Country::Estonia, Country::Iran, Country::Bulgaria,
};

inline std::string toString(Country country)
Expand Down Expand Up @@ -112,7 +113,8 @@ inline std::string toString(Country country)
{Country::Ireland, "Ireland"},
{Country::Belarus, "Belarus"},
{Country::Estonia, "Estonia"},
{Country::Iran, "Iran"}
{Country::Iran, "Iran"},
{Country::Bulgaria, "Bulgaria"},
};

return countryToStringMapping.at(country);
Expand Down
21 changes: 11 additions & 10 deletions src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "data/belgium/BelgianPeopleNames.h"
#include "data/Bio.h"
#include "data/brazil/BrazilianPeopleNames.h"
#include "data/bulgaria/BulgarianPeopleNames.h"
#include "data/canada/CanadianPeopleNames.h"
#include "data/china/ChinesePeopleNames.h"
#include "data/croatia/CroatianPeopleNames.h"
Expand All @@ -39,8 +40,8 @@
#include "data/macedonia/MacedonianPeopleNames.h"
#include "data/mexico/MexicanPeopleNames.h"
#include "data/Nationalities.h"
#include "data/netherlands/DutchPeopleNames.h"
#include "data/nepal/NepalesePeopleNames.h"
#include "data/netherlands/DutchPeopleNames.h"
#include "data/norway/NorwegianPeopleNames.h"
#include "data/poland/PolishPeopleNames.h"
#include "data/portugal/PortuguesePeopleNames.h"
Expand All @@ -56,9 +57,9 @@
#include "data/ukraine/UkrainianPeopleNames.h"
#include "data/usa/UsaPeopleNames.h"
#include "data/ZodiacSigns.h"
#include "faker-cxx/Word.h"
#include "faker-cxx/Internet.h"
#include "faker-cxx/Helper.h"
#include "faker-cxx/Internet.h"
#include "faker-cxx/Word.h"
#include "fmt/format.h"

namespace faker
Expand Down Expand Up @@ -89,7 +90,9 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Serbia, serbianPeopleNames}, {Country::Macedonia, macedonianPeopleNames},
{Country::Latvia, latvianPeopleNames}, {Country::Ireland, irishPeopleNames},
{Country::Belarus, belarusianPeopleNames}, {Country::Estonia, estonianPeopleNames},
{Country::Albania, albanianPeopleNames}, {Country::Iran,persianPeopleNames}};
{Country::Albania, albanianPeopleNames}, {Country::Iran, persianPeopleNames},
{Country::Bulgaria, bulgarianPeopleNames},
};

std::string middleNameForCountry(Country country, std::optional<Sex> sex);
std::string prefixForCountry(Country country, std::optional<Sex> sex);
Expand Down Expand Up @@ -267,18 +270,16 @@ std::string Person::prefix(std::optional<Sex> sex)
return Helper::arrayElement<std::string>(allPrefixes);
}


std::string Person::bio()
{
const auto randomBioFormat = Helper::arrayElement<std::string>(bioFormats);


const auto dataGeneratorsMapping = std::map<std::string, std::function<std::string()>>{
{"bio_part", []() { return Helper::arrayElement(bioPart);}},
{"bio_part", []() { return Helper::arrayElement(bioPart); }},
{"bio_supporter", []() { return Helper::arrayElement(bioSupporter); }},
{"noun", []() { return Word::noun();}},
{"emoji", []() { return Internet::emoji();}}};
{"noun", []() { return Word::noun(); }},
{"emoji", []() { return Internet::emoji(); }}};

return FormatHelper::fillTokenValues(randomBioFormat, dataGeneratorsMapping);
}

Expand Down
93 changes: 42 additions & 51 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "gtest/gtest.h"


#include "../../common/BioHelper.h"
#include "../../common/StringHelper.h"
#include "data/albania/AlbanianPeopleNames.h"
Expand All @@ -13,6 +12,7 @@
#include "data/austria/AustrianPeopleNames.h"
#include "data/belarus/BelarusianPeopleNames.h"
#include "data/belgium/BelgianPeopleNames.h"
#include "data/bulgaria/BulgarianPeopleNames.h"
#include "data/canada/CanadianPeopleNames.h"
#include "data/china/ChinesePeopleNames.h"
#include "data/croatia/CroatianPeopleNames.h"
Expand All @@ -39,8 +39,8 @@
#include "data/macedonia/MacedonianPeopleNames.h"
#include "data/mexico/MexicanPeopleNames.h"
#include "data/Nationalities.h"
#include "data/netherlands/DutchPeopleNames.h"
#include "data/nepal/NepalesePeopleNames.h"
#include "data/netherlands/DutchPeopleNames.h"
#include "data/norway/NorwegianPeopleNames.h"
#include "data/poland/PolishPeopleNames.h"
#include "data/portugal/PortuguesePeopleNames.h"
Expand Down Expand Up @@ -88,7 +88,9 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Serbia, serbianPeopleNames}, {Country::Macedonia, macedonianPeopleNames},
{Country::Latvia, latvianPeopleNames}, {Country::Ireland, irishPeopleNames},
{Country::Belarus, belarusianPeopleNames}, {Country::Estonia, estonianPeopleNames},
{Country::Albania, albanianPeopleNames}, {Country::Iran,persianPeopleNames}};
{Country::Albania, albanianPeopleNames}, {Country::Iran, persianPeopleNames},
{Country::Bulgaria, bulgarianPeopleNames},
};

const std::map<Country, std::string> generatedTestName{
{Country::England, "shouldGenerateEnglishName"}, {Country::France, "shouldGenerateFrenchName"},
Expand All @@ -112,7 +114,9 @@ const std::map<Country, std::string> generatedTestName{
{Country::Serbia, "shouldGenerateSerbianName"}, {Country::Macedonia, "shouldGenerateMacedonianName"},
{Country::Latvia, "shouldGenerateLatvianName"}, {Country::Ireland, "shouldGenerateIrishName"},
{Country::Belarus, "shouldGenerateBelarusianName"}, {Country::Estonia, "shouldGenerateEstonianName"},
{Country::Albania, "shouldGenerateAlbanianName"}, {Country::Iran, "shouldGeneratePersianName"}};
{Country::Albania, "shouldGenerateAlbanianName"}, {Country::Iran, "shouldGeneratePersianName"},
{Country::Bulgaria, "shouldGenerateBulgarianName"},
};
}

class PersonTest : public TestWithParam<Country>
Expand Down Expand Up @@ -473,10 +477,12 @@ TEST_F(PersonTest, shouldGenerateChineseZodiacs)
{ return generatedChineseZodiacs == chineseZodiac; }));
}

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

TEST_P(PersonSexSuite, shouldTranslateSexCorrectly) {
TEST_P(PersonSexSuite, shouldTranslateSexCorrectly)
{
Language language = GetParam().first;
Sex sex = GetParam().second;

Expand All @@ -487,48 +493,33 @@ TEST_P(PersonSexSuite, shouldTranslateSexCorrectly) {
}

std::vector<std::pair<Language, Sex>> languageSexPairs = {
{Language::English, Sex::Male}, {Language::English, Sex::Female},
{Language::Polish, Sex::Male}, {Language::Polish, Sex::Female},
{Language::Italian, Sex::Male}, {Language::Italian, Sex::Female},
{Language::French, Sex::Male}, {Language::French, Sex::Female},
{Language::German, Sex::Male}, {Language::German, Sex::Female},
{Language::Russian, Sex::Male}, {Language::Russian, Sex::Female},
{Language::Romanian, Sex::Male}, {Language::Romanian, Sex::Female},
{Language::Hindi, Sex::Male}, {Language::Hindi, Sex::Female},
{Language::Finnish, Sex::Male}, {Language::Finnish, Sex::Female},
{Language::Nepali, Sex::Male}, {Language::Nepali, Sex::Female},
{Language::Spanish, Sex::Male}, {Language::Spanish, Sex::Female},
{Language::Turkish, Sex::Male}, {Language::Turkish, Sex::Female},
{Language::Czech, Sex::Male}, {Language::Czech, Sex::Female},
{Language::Slovak, Sex::Male}, {Language::Slovak, Sex::Female},
{Language::Ukrainian, Sex::Male}, {Language::Ukrainian, Sex::Female},
{Language::Danish, Sex::Male}, {Language::Danish, Sex::Female},
{Language::Swedish, Sex::Male}, {Language::Swedish, Sex::Female},
{Language::Portuguese, Sex::Male}, {Language::Portuguese, Sex::Female},
{Language::Norwegian, Sex::Male}, {Language::Norwegian, Sex::Female},
{Language::Japanese, Sex::Male}, {Language::Japanese, Sex::Female},
{Language::Hungarian, Sex::Male}, {Language::Hungarian, Sex::Female},
{Language::Croatian, Sex::Male}, {Language::Croatian, Sex::Female},
{Language::Greek, Sex::Male}, {Language::Greek, Sex::Female},
{Language::Slovene, Sex::Male}, {Language::Slovene, Sex::Female},
{Language::Dutch, Sex::Male}, {Language::Dutch, Sex::Female},
{Language::Mandarin, Sex::Male}, {Language::Mandarin, Sex::Female},
{Language::Korean, Sex::Male}, {Language::Korean, Sex::Female},
{Language::Serbian, Sex::Male}, {Language::Serbian, Sex::Female},
{Language::Macedonian, Sex::Male}, {Language::Macedonian, Sex::Female},
{Language::Albanian, Sex::Male}, {Language::Albanian, Sex::Female},
{Language::Latvian, Sex::Male}, {Language::Latvian, Sex::Female},
{Language::Irish, Sex::Male}, {Language::Irish, Sex::Female},
{Language::Belarusian, Sex::Male}, {Language::Belarusian, Sex::Female},
{Language::Estonian, Sex::Male}, {Language::Estonian, Sex::Female}
};

INSTANTIATE_TEST_SUITE_P(
TestPersonSexTranslation,
PersonSexSuite,
testing::ValuesIn(languageSexPairs),
[](const testing::TestParamInfo<PersonSexSuite::ParamType>& info) {
auto param = info.param;
return toString(param.first) + "_" + toString(param.second);
}
);
{Language::English, Sex::Male}, {Language::English, Sex::Female}, {Language::Polish, Sex::Male},
{Language::Polish, Sex::Female}, {Language::Italian, Sex::Male}, {Language::Italian, Sex::Female},
{Language::French, Sex::Male}, {Language::French, Sex::Female}, {Language::German, Sex::Male},
{Language::German, Sex::Female}, {Language::Russian, Sex::Male}, {Language::Russian, Sex::Female},
{Language::Romanian, Sex::Male}, {Language::Romanian, Sex::Female}, {Language::Hindi, Sex::Male},
{Language::Hindi, Sex::Female}, {Language::Finnish, Sex::Male}, {Language::Finnish, Sex::Female},
{Language::Nepali, Sex::Male}, {Language::Nepali, Sex::Female}, {Language::Spanish, Sex::Male},
{Language::Spanish, Sex::Female}, {Language::Turkish, Sex::Male}, {Language::Turkish, Sex::Female},
{Language::Czech, Sex::Male}, {Language::Czech, Sex::Female}, {Language::Slovak, Sex::Male},
{Language::Slovak, Sex::Female}, {Language::Ukrainian, Sex::Male}, {Language::Ukrainian, Sex::Female},
{Language::Danish, Sex::Male}, {Language::Danish, Sex::Female}, {Language::Swedish, Sex::Male},
{Language::Swedish, Sex::Female}, {Language::Portuguese, Sex::Male}, {Language::Portuguese, Sex::Female},
{Language::Norwegian, Sex::Male}, {Language::Norwegian, Sex::Female}, {Language::Japanese, Sex::Male},
{Language::Japanese, Sex::Female}, {Language::Hungarian, Sex::Male}, {Language::Hungarian, Sex::Female},
{Language::Croatian, Sex::Male}, {Language::Croatian, Sex::Female}, {Language::Greek, Sex::Male},
{Language::Greek, Sex::Female}, {Language::Slovene, Sex::Male}, {Language::Slovene, Sex::Female},
{Language::Dutch, Sex::Male}, {Language::Dutch, Sex::Female}, {Language::Mandarin, Sex::Male},
{Language::Mandarin, Sex::Female}, {Language::Korean, Sex::Male}, {Language::Korean, Sex::Female},
{Language::Serbian, Sex::Male}, {Language::Serbian, Sex::Female}, {Language::Macedonian, Sex::Male},
{Language::Macedonian, Sex::Female}, {Language::Albanian, Sex::Male}, {Language::Albanian, Sex::Female},
{Language::Latvian, Sex::Male}, {Language::Latvian, Sex::Female}, {Language::Irish, Sex::Male},
{Language::Irish, Sex::Female}, {Language::Belarusian, Sex::Male}, {Language::Belarusian, Sex::Female},
{Language::Estonian, Sex::Male}, {Language::Estonian, Sex::Female}};

INSTANTIATE_TEST_SUITE_P(TestPersonSexTranslation, PersonSexSuite, testing::ValuesIn(languageSexPairs),
[](const testing::TestParamInfo<PersonSexSuite::ParamType>& info)
{
auto param = info.param;
return toString(param.first) + "_" + toString(param.second);
});
20 changes: 20 additions & 0 deletions src/modules/person/data/bulgaria/BulgarianFirstNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> bulgarianMalesFirstNames = {
"Aleksandar", "Angel", "Anton", "Boris", "Boyan", "Dimitar", "Emil", "Georgi", "Hristo", "Iliya",
"Ivan", "Kaloyan", "Kiril", "Lubomir", "Lyubomir", "Mihail", "Nikolay", "Ognian", "Petar", "Plamen",
"Radoslav", "Stefan", "Stoyan", "Todor", "Valentin", "Vasil", "Viktor", "Vladimir", "Yordan", "Zahari",
};

const std::vector<std::string> bulgarianFemalesFirstNames = {
"Aleksandra", "Anastasiya", "Anna", "Borislava", "Daniela", "Diana", "Ekaterina", "Elitsa",
"Gabriela", "Gergana", "Iliana", "Ivanka", "Kalina", "Katerina", "Lidiya", "Maria",
"Margarita", "Nadezhda", "Nataliya", "Nevena", "Olya", "Petya", "Radostina", "Rumyana",
"Silvia", "Sofiya", "Svetlana", "Tsvetanka", "Vanya", "Vesela", "Yana", "Zoya",
};
}
13 changes: 13 additions & 0 deletions src/modules/person/data/bulgaria/BulgarianLastNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> bulgarianLastNames = {
"Angelov", "Atanasov", "Bozhilov", "Dimitrov", "Draganov", "Georgiev", "Hristov", "Iliev", "Ivanov",
"Kolev", "Kovachev", "Lazarov", "Mihaylov", "Nikolov", "Petrov", "Popov", "Radev", "Simeonov",
"Stefanov", "Stoyanov", "Todorov", "Vasilev", "Vladimirov", "Yankov", "Zahariev",
};
}
22 changes: 22 additions & 0 deletions src/modules/person/data/bulgaria/BulgarianPeopleNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "../NameFormats.h"
#include "../PeopleNames.h"
#include "BulgarianFirstNames.h"
#include "BulgarianLastNames.h"
#include "BulgarianPrefixes.h"
#include "BulgarianSuffixes.h"

namespace faker
{
const NameFormats bulgarianPersonNameFormats{{
{"{firstName} {lastName}", 8},
{"{prefix} {firstName} {lastName}", 1},
{"{firstName} {lastName} {suffix}", 1},
}};

const PeopleNames bulgarianPeopleNames{
{bulgarianMalesFirstNames, {}, bulgarianLastNames, bulgarianMalesPrefixes, bulgarianSuffixes},
{bulgarianFemalesFirstNames, {}, bulgarianLastNames, bulgarianFemalesPrefixes, bulgarianSuffixes},
bulgarianPersonNameFormats};
}
11 changes: 11 additions & 0 deletions src/modules/person/data/bulgaria/BulgarianPrefixes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> bulgarianMalesPrefixes{"Г-н", "Д-р", "Проф."};

const std::vector<std::string> bulgarianFemalesPrefixes{"Г-жа", "Г-ца", "Д-р", "Проф."};
}
9 changes: 9 additions & 0 deletions src/modules/person/data/bulgaria/BulgarianSuffixes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> bulgarianSuffixes{"мл.", "ст."};
}
Loading

0 comments on commit 077f86e

Please sign in to comment.