Skip to content

Commit

Permalink
add norwegian names (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal authored Nov 16, 2023
1 parent 032a7ee commit e1db8c2
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 6 deletions.
7 changes: 4 additions & 3 deletions include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ enum class Country
Ukraine,
Denmark,
Sweden,
Brazil
Brazil,
Norway
};

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::Denmark, Country::Sweden, Country::Brazil, Country::Norway};

inline std::string toString(Country country)
{
Expand All @@ -44,7 +45,7 @@ inline std::string toString(Country country)
{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::Brazil, "Brazil"}, {Country::Norway, "Norway"}};

return countryToStringMapping.at(country);
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "data/JobTitles.h"
#include "data/Nationalities.h"
#include "data/nepal/NepalesePeopleNames.h"
#include "data/norway/NorwegianPeopleNames.h"
#include "data/poland/PolishPeopleNames.h"
#include "data/romania/RomanianPeopleNames.h"
#include "data/russia/RussianPeopleNames.h"
Expand Down Expand Up @@ -48,7 +49,7 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}};
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames}};

std::string middleNameForCountry(Country country, std::optional<Sex> sex);
std::string prefixForCountry(Country country, std::optional<Sex> sex);
Expand Down
5 changes: 3 additions & 2 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "data/JobTitles.h"
#include "data/Nationalities.h"
#include "data/nepal/NepalesePeopleNames.h"
#include "data/norway/NorwegianPeopleNames.h"
#include "data/poland/PolishPeopleNames.h"
#include "data/romania/RomanianPeopleNames.h"
#include "data/russia/RussianPeopleNames.h"
Expand Down Expand Up @@ -48,7 +49,7 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}};
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames}};

const std::map<Country, std::string> generatedTestName{
{Country::England, "shouldGenerateEnglishName"}, {Country::France, "shouldGenerateFrenchName"},
Expand All @@ -60,7 +61,7 @@ const std::map<Country, std::string> generatedTestName{
{Country::Czech, "shouldGenerateCzechName"}, {Country::Slovakia, "shouldGenerateSlovakName"},
{Country::Ukraine, "shouldGenerateUkrainianName"}, {Country::Denmark, "shouldGenerateDanishName"},
{Country::Sweden, "shouldGenerateSwedishName"}, {Country::Usa, "shouldGenerateAmericanName"},
{Country::Brazil, "shouldGenerateBrazilianName"}};
{Country::Brazil, "shouldGenerateBrazilianName"}, {Country::Norway, "shouldGenerateNorwegianName"}};
}

class PersonTest : public TestWithParam<Country>
Expand Down
21 changes: 21 additions & 0 deletions src/modules/person/data/norway/NorwegianFirstNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> norwegianMalesFirstNames = {
"Markus", "Mathias", "Kristian", "Jonas", "Andreas", "Alexander", "Martin", "Sander", "Daniel", "Magnus",
"Henrik", "Tobias", "Kristoffer", "Emil", "Adrian", "Sebastian", "Marius", "Elias", "Fredrik", "Thomas",
"Sondre", "Benjamin", "Jakob", "Oliver", "Lucas", "Oskar", "Nikolai", "Filip", "Mats", "William",
"Erik", "Simen", "Ole", "Eirik", "Isak", "Kasper", "Noah", "Lars", "Joakim", "Johannes",
"Håkon", "Sindre", "Jørgen", "Herman", "Anders", "Jonathan", "Even", "Theodor", "Mikkel", "Aksel"};

const std::vector<std::string> norwegianFemalesFirstNames = {
"Emma", "Sara", "Thea", "Ida", "Julie", "Nora", "Emilie", "Ingrid", "Hanna", "Maria",
"Sofie", "Anna", "Malin", "Amalie", "Vilde", "Frida", "Andrea", "Tuva", "Victoria", "Mia",
"Karoline", "Mathilde", "Martine", "Linnea", "Marte", "Hedda", "Marie", "Helene", "Silje", "Leah",
"Maja", "Elise", "Oda", "Kristine", "Aurora", "Kaja", "Camilla", "Mari", "Maren", "Mina",
"Selma", "Jenny", "Celine", "Eline", "Sunniva", "Natalie", "Tiril", "Synne", "Sandra", "Madeleine"};
}
24 changes: 24 additions & 0 deletions src/modules/person/data/norway/NorwegianLastNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> norwegianLastNames = {
"Johansen", "Hansen", "Andersen", "Kristiansen", "Larsen", "Olsen", "Solberg",
"Andresen", "Pedersen", "Nilsen", "Berg", "Halvorsen", "Karlsen", "Svendsen",
"Jensen", "Haugen", "Martinsen", "Eriksen", "Sørensen", "Johnsen", "Myhrer",
"Johannessen", "Nielsen", "Hagen", "Pettersen", "Bakke", "Skuterud", "Løken",
"Gundersen", "Strand", "Jørgensen", "Kvarme", "Røed", "Sæther", "Stensrud",
"Moe", "Kristoffersen", "Jakobsen", "Holm", "Aas", "Lie", "Moen",
"Andreassen", "Vedvik", "Nguyen", "Jacobsen", "Torgersen", "Ruud", "Krogh",
"Christiansen", "Bjerke", "Aalerud", "Borge", "Sørlie", "Berge", "Østli",
"Ødegård", "Torp", "Henriksen", "Haukelidsæter", "Fjeld", "Danielsen", "Aasen",
"Fredriksen", "Dahl", "Berntsen", "Arnesen", "Wold", "Thoresen", "Solheim",
"Skoglund", "Bakken", "Amundsen", "Solli", "Smogeli", "Kristensen", "Glosli",
"Fossum", "Evensen", "Eide", "Carlsen", "Østby", "Vegge", "Tangen",
"Smedsrud", "Olstad", "Lunde", "Kleven", "Huseby", "Bjørnstad", "Ryan",
"Rasmussen", "Nygård", "Nordskaug", "Nordby", "Mathisen", "Hopland", "Gran",
"Finstad", "Edvardsen"};
}
20 changes: 20 additions & 0 deletions src/modules/person/data/norway/NorwegianPeopleNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "../NameFormats.h"
#include "../PeopleNames.h"
#include "NorwegianFirstNames.h"
#include "NorwegianLastNames.h"
#include "NorwegianPrefixes.h"
#include "NorwegianSuffixes.h"

namespace faker
{
const NameFormats norwegianPersonNameFormats{
{{"{prefix} {firstName} {lastName}", 1}, {"{firstName} {lastName}", 9}, {"{firstName} {lastName} {suffix}", 1}}};

const PeopleNames norwegianPeopleNames{
{norwegianMalesFirstNames, {}, norwegianLastNames, norwegianPrefixes, norwegianSuffixes},
{norwegianFemalesFirstNames, {}, norwegianLastNames, norwegianPrefixes, norwegianSuffixes},
norwegianPersonNameFormats};

}
9 changes: 9 additions & 0 deletions src/modules/person/data/norway/NorwegianPrefixes.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> norwegianPrefixes{"Dr.", "Prof."};
}
9 changes: 9 additions & 0 deletions src/modules/person/data/norway/NorwegianSuffixes.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> norwegianSuffixes{"Jr.", "Sr.", "I", "II", "III", "IV", "V"};
}

0 comments on commit e1db8c2

Please sign in to comment.