Skip to content

Commit

Permalink
Merge branch 'cieslarmichal:main' into feature/string_guarantee
Browse files Browse the repository at this point in the history
  • Loading branch information
braw-lee authored Nov 21, 2023
2 parents ab78abc + 119d752 commit e0e6785
Show file tree
Hide file tree
Showing 23 changed files with 1,913 additions and 65 deletions.
70 changes: 50 additions & 20 deletions include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,64 @@ enum class Country
Switzerland,
Belgium,
Nederlands,
China,
Korea,
Canada,
Mexico,
Argentina,
Australia,
};

const std::vector<Country> countries{
Country::Usa, Country::England, Country::Poland, Country::Italy, Country::France, Country::Germany,
Country::Russia, Country::Romania, Country::India, Country::Finland, Country::Nepal, Country::Spain,
Country::Turkey, Country::Czech, Country::Slovakia, Country::Ukraine, Country::Denmark, Country::Sweden,
Country::Brazil, Country::Norway, Country::Japan, Country::Portugal, Country::Hungary, Country::Croatia,
Country::Greece, Country::Slovenia, Country::Austria, Country::Switzerland, Country::Belgium, Country::Nederlands,
Country::Usa, Country::England, Country::Poland, Country::Italy, Country::France,
Country::Germany, Country::Russia, Country::Romania, Country::India, Country::Finland,
Country::Nepal, Country::Spain, Country::Turkey, Country::Czech, Country::Slovakia,
Country::Ukraine, Country::Denmark, Country::Sweden, Country::Brazil, Country::Norway,
Country::Japan, Country::Portugal, Country::Hungary, Country::Croatia, Country::Greece,
Country::Slovenia, Country::Austria, Country::Switzerland, Country::Belgium, Country::Nederlands,
Country::China, Country::Korea, Country::Canada, Country::Mexico, Country::Argentina,
Country::Australia,
};

inline std::string toString(Country country)
{
std::map<Country, std::string> countryToStringMapping{
{Country::Usa, "Usa"}, {Country::England, "England"},
{Country::Poland, "Poland"}, {Country::Italy, "Italy"},
{Country::France, "France"}, {Country::Germany, "Germany"},
{Country::Russia, "Russia"}, {Country::Romania, "Romania"},
{Country::India, "India"}, {Country::Finland, "Finland"},
{Country::Nepal, "Nepal"}, {Country::Spain, "Spain"},
{Country::Turkey, "Turkey"}, {Country::Czech, "Czech"},
{Country::Slovakia, "Slovakia"}, {Country::Ukraine, "Ukraine"},
{Country::Denmark, "Denmark"}, {Country::Sweden, "Sweden"},
{Country::Brazil, "Brazil"}, {Country::Norway, "Norway"},
{Country::Japan, "Japan"}, {Country::Portugal, "Portugal"},
{Country::Hungary, "Hungary"}, {Country::Croatia, "Croatia"},
{Country::Greece, "Greece"}, {Country::Slovenia, "Slovenia"},
{Country::Austria, "Austria"}, {Country::Switzerland, "Switzerland"},
{Country::Belgium, "Belgium"}, {Country::Nederlands, "Nederlands"},
{Country::Usa, "Usa"},
{Country::England, "England"},
{Country::Poland, "Poland"},
{Country::Italy, "Italy"},
{Country::France, "France"},
{Country::Germany, "Germany"},
{Country::Russia, "Russia"},
{Country::Romania, "Romania"},
{Country::India, "India"},
{Country::Finland, "Finland"},
{Country::Nepal, "Nepal"},
{Country::Spain, "Spain"},
{Country::Turkey, "Turkey"},
{Country::Czech, "Czech"},
{Country::Slovakia, "Slovakia"},
{Country::Ukraine, "Ukraine"},
{Country::Denmark, "Denmark"},
{Country::Sweden, "Sweden"},
{Country::Brazil, "Brazil"},
{Country::Norway, "Norway"},
{Country::Japan, "Japan"},
{Country::Portugal, "Portugal"},
{Country::Hungary, "Hungary"},
{Country::Croatia, "Croatia"},
{Country::Greece, "Greece"},
{Country::Slovenia, "Slovenia"},
{Country::Austria, "Austria"},
{Country::Switzerland, "Switzerland"},
{Country::Belgium, "Belgium"},
{Country::Nederlands, "Nederlands"},
{Country::China, "China"},
{Country::Korea, "Korea"},
{Country::Canada, "Canada"},
{Country::Mexico, "Mexico"},
{Country::Argentina, "Argentina"},
{Country::Australia, "Australia"},
};

return countryToStringMapping.at(country);
Expand Down
39 changes: 24 additions & 15 deletions src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#include <set>

#include "../../common/FormatHelper.h"
#include "data/argentina/ArgentinianPeopleNames.h"
#include "data/australia/AustralianPeopleNames.h"
#include "data/austria/AustrianPeopleNames.h"
#include "data/belgium/BelgianPeopleNames.h"
#include "data/brazil/BrazilianPeopleNames.h"
#include "data/canada/CanadianPeopleNames.h"
#include "data/china/ChinesePeopleNames.h"
#include "data/croatia/CroatianPeopleNames.h"
#include "data/czech/CzechPeopleNames.h"
#include "data/denmark/DanishPeopleNames.h"
Expand All @@ -23,7 +27,9 @@
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/korea/KoreanPeopleNames.h"
#include "data/Languages.h"
#include "data/mexico/MexicanPeopleNames.h"
#include "data/Nationalities.h"
#include "data/nederlands/DutchPeopleNames.h"
#include "data/nepal/NepalesePeopleNames.h"
Expand Down Expand Up @@ -51,21 +57,24 @@ namespace
const std::vector<std::string> sexes{"Male", "Female"};

const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::England, englishPeopleNames}, {Country::France, frenchPeopleNames},
{Country::Germany, germanPeopleNames}, {Country::Italy, italianPeopleNames},
{Country::Poland, polishPeopleNames}, {Country::Russia, russianPeopleNames},
{Country::Romania, romanianPeopleNames}, {Country::India, indianPeopleNames},
{Country::Finland, finnishPeopleNames}, {Country::Nepal, nepalesePeopleNames},
{Country::Spain, spanishPeopleNames}, {Country::Turkey, turkishPeopleNames},
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames}, {Country::Portugal, portuguesePeopleNames},
{Country::Hungary, hungarianPeopleNames}, {Country::Croatia, croatianPeopleNames},
{Country::Greece, greekPeopleNames}, {Country::Slovenia, slovenianPeopleNames},
{Country::Austria, austrianPeopleNames}, {Country::Switzerland, swissPeopleNames},
{Country::Belgium, belgianPeopleNames}, {Country::Nederlands, dutchPeopleNames},
{Country::England, englishPeopleNames}, {Country::France, frenchPeopleNames},
{Country::Germany, germanPeopleNames}, {Country::Italy, italianPeopleNames},
{Country::Poland, polishPeopleNames}, {Country::Russia, russianPeopleNames},
{Country::Romania, romanianPeopleNames}, {Country::India, indianPeopleNames},
{Country::Finland, finnishPeopleNames}, {Country::Nepal, nepalesePeopleNames},
{Country::Spain, spanishPeopleNames}, {Country::Turkey, turkishPeopleNames},
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames}, {Country::Portugal, portuguesePeopleNames},
{Country::Hungary, hungarianPeopleNames}, {Country::Croatia, croatianPeopleNames},
{Country::Greece, greekPeopleNames}, {Country::Slovenia, slovenianPeopleNames},
{Country::Austria, austrianPeopleNames}, {Country::Switzerland, swissPeopleNames},
{Country::Belgium, belgianPeopleNames}, {Country::Nederlands, dutchPeopleNames},
{Country::China, chinesePeopleNames}, {Country::Korea, koreanPeopleNames},
{Country::Canada, canadianPeopleNames}, {Country::Mexico, mexicanPeopleNames},
{Country::Argentina, argentinianPeopleNames}, {Country::Australia, australianPeopleNames},
};

std::string middleNameForCountry(Country country, std::optional<Sex> sex);
Expand Down
72 changes: 42 additions & 30 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
#include "gtest/gtest.h"

#include "../../common/StringHelper.h"
#include "data/argentina/ArgentinianPeopleNames.h"
#include "data/australia/AustralianPeopleNames.h"
#include "data/austria/AustrianPeopleNames.h"
#include "data/belgium/BelgianPeopleNames.h"
#include "data/canada/CanadianPeopleNames.h"
#include "data/china/ChinesePeopleNames.h"
#include "data/croatia/CroatianPeopleNames.h"
#include "data/czech/CzechPeopleNames.h"
#include "data/denmark/DanishPeopleNames.h"
Expand All @@ -22,7 +26,9 @@
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/korea/KoreanPeopleNames.h"
#include "data/Languages.h"
#include "data/mexico/MexicanPeopleNames.h"
#include "data/Nationalities.h"
#include "data/nederlands/DutchPeopleNames.h"
#include "data/nepal/NepalesePeopleNames.h"
Expand Down Expand Up @@ -51,39 +57,45 @@ namespace
const std::vector<std::string> sexes{"Male", "Female"};

const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::England, englishPeopleNames}, {Country::France, frenchPeopleNames},
{Country::Germany, germanPeopleNames}, {Country::Italy, italianPeopleNames},
{Country::Poland, polishPeopleNames}, {Country::Russia, russianPeopleNames},
{Country::Romania, romanianPeopleNames}, {Country::India, indianPeopleNames},
{Country::Finland, finnishPeopleNames}, {Country::Nepal, nepalesePeopleNames},
{Country::Spain, spanishPeopleNames}, {Country::Turkey, turkishPeopleNames},
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames}, {Country::Portugal, portuguesePeopleNames},
{Country::Hungary, hungarianPeopleNames}, {Country::Croatia, croatianPeopleNames},
{Country::Greece, greekPeopleNames}, {Country::Slovenia, slovenianPeopleNames},
{Country::Austria, austrianPeopleNames}, {Country::Switzerland, swissPeopleNames},
{Country::Belgium, belgianPeopleNames}, {Country::Nederlands, dutchPeopleNames},
{Country::England, englishPeopleNames}, {Country::France, frenchPeopleNames},
{Country::Germany, germanPeopleNames}, {Country::Italy, italianPeopleNames},
{Country::Poland, polishPeopleNames}, {Country::Russia, russianPeopleNames},
{Country::Romania, romanianPeopleNames}, {Country::India, indianPeopleNames},
{Country::Finland, finnishPeopleNames}, {Country::Nepal, nepalesePeopleNames},
{Country::Spain, spanishPeopleNames}, {Country::Turkey, turkishPeopleNames},
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames}, {Country::Portugal, portuguesePeopleNames},
{Country::Hungary, hungarianPeopleNames}, {Country::Croatia, croatianPeopleNames},
{Country::Greece, greekPeopleNames}, {Country::Slovenia, slovenianPeopleNames},
{Country::Austria, austrianPeopleNames}, {Country::Switzerland, swissPeopleNames},
{Country::Belgium, belgianPeopleNames}, {Country::Nederlands, dutchPeopleNames},
{Country::China, chinesePeopleNames}, {Country::Korea, koreanPeopleNames},
{Country::Canada, canadianPeopleNames}, {Country::Mexico, mexicanPeopleNames},
{Country::Argentina, argentinianPeopleNames}, {Country::Australia, australianPeopleNames},
};

const std::map<Country, std::string> generatedTestName{
{Country::England, "shouldGenerateEnglishName"}, {Country::France, "shouldGenerateFrenchName"},
{Country::Germany, "shouldGenerateGermanName"}, {Country::Italy, "shouldGenerateItalianName"},
{Country::Poland, "shouldGeneratePolishName"}, {Country::Russia, "shouldGenerateRussianName"},
{Country::Romania, "shouldGenerateRomanianName"}, {Country::India, "shouldGenerateIndianName"},
{Country::Finland, "shouldGenerateFinnishName"}, {Country::Nepal, "shouldGenerateNepaleseName"},
{Country::Spain, "shouldGenerateSpanishName"}, {Country::Turkey, "shouldGenerateTurkishName"},
{Country::Czech, "shouldGenerateCzechName"}, {Country::Slovakia, "shouldGenerateSlovakName"},
{Country::Ukraine, "shouldGenerateUkrainianName"}, {Country::Denmark, "shouldGenerateDanishName"},
{Country::Sweden, "shouldGenerateSwedishName"}, {Country::Usa, "shouldGenerateAmericanName"},
{Country::Brazil, "shouldGenerateBrazilianName"}, {Country::Norway, "shouldGenerateNorwegianName"},
{Country::Japan, "shouldGenerateJapaneseName"}, {Country::Portugal, "shouldGeneratePortugueseName"},
{Country::Hungary, "shouldGenerateHungarianName"}, {Country::Croatia, "shouldGenerateCroatianName"},
{Country::Greece, "shouldGenerateGreekName"}, {Country::Slovenia, "shouldGenerateSlovenianName"},
{Country::Austria, "shouldGenerateAustrianName"}, {Country::Switzerland, "shouldGenerateSwissName"},
{Country::Belgium, "shouldGenerateBelgianName"}, {Country::Nederlands, "shouldGenerateDutchName"},
{Country::England, "shouldGenerateEnglishName"}, {Country::France, "shouldGenerateFrenchName"},
{Country::Germany, "shouldGenerateGermanName"}, {Country::Italy, "shouldGenerateItalianName"},
{Country::Poland, "shouldGeneratePolishName"}, {Country::Russia, "shouldGenerateRussianName"},
{Country::Romania, "shouldGenerateRomanianName"}, {Country::India, "shouldGenerateIndianName"},
{Country::Finland, "shouldGenerateFinnishName"}, {Country::Nepal, "shouldGenerateNepaleseName"},
{Country::Spain, "shouldGenerateSpanishName"}, {Country::Turkey, "shouldGenerateTurkishName"},
{Country::Czech, "shouldGenerateCzechName"}, {Country::Slovakia, "shouldGenerateSlovakName"},
{Country::Ukraine, "shouldGenerateUkrainianName"}, {Country::Denmark, "shouldGenerateDanishName"},
{Country::Sweden, "shouldGenerateSwedishName"}, {Country::Usa, "shouldGenerateAmericanName"},
{Country::Brazil, "shouldGenerateBrazilianName"}, {Country::Norway, "shouldGenerateNorwegianName"},
{Country::Japan, "shouldGenerateJapaneseName"}, {Country::Portugal, "shouldGeneratePortugueseName"},
{Country::Hungary, "shouldGenerateHungarianName"}, {Country::Croatia, "shouldGenerateCroatianName"},
{Country::Greece, "shouldGenerateGreekName"}, {Country::Slovenia, "shouldGenerateSlovenianName"},
{Country::Austria, "shouldGenerateAustrianName"}, {Country::Switzerland, "shouldGenerateSwissName"},
{Country::Belgium, "shouldGenerateBelgianName"}, {Country::Nederlands, "shouldGenerateDutchName"},
{Country::China, "shouldGenerateChineseName"}, {Country::Korea, "shouldGenerateKoreanName"},
{Country::Canada, "shouldGenerateCanadianName"}, {Country::Mexico, "shouldGenerateMexicanName"},
{Country::Argentina, "shouldGenerateArgentinianName"}, {Country::Australia, "shouldGenerateAustralianName"},
};
}

Expand Down
Loading

0 comments on commit e0e6785

Please sign in to comment.