Skip to content

Commit

Permalink
Added Iceland people names. (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
flamingchad authored Jan 3, 2024
1 parent 18f450f commit 3f8df54
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 40 deletions.
41 changes: 22 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ set(FAKER_UT_SOURCES
add_library(${LIBRARY_NAME} ${FAKER_SOURCES})

target_include_directories(
${LIBRARY_NAME}
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include"
PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include"
)
${LIBRARY_NAME}
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include"
PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")

if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_subdirectory(externals/fmt)
set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include")
target_link_libraries(${LIBRARY_NAME} PRIVATE fmt)
Expand All @@ -124,9 +125,9 @@ if(BUILD_FAKER_TESTS)
add_subdirectory(externals/googletest)

set(GTEST_INCLUDE_DIR
"${CMAKE_SOURCE_DIR}/externals/googletest/googletest/include")
"${CMAKE_SOURCE_DIR}/externals/googletest/googletest/include")
set(GMOCK_INCLUDE_DIR
"${CMAKE_SOURCE_DIR}/externals/googletest/googlemock/include")
"${CMAKE_SOURCE_DIR}/externals/googletest/googlemock/include")

enable_testing()

Expand All @@ -139,24 +140,26 @@ if(BUILD_FAKER_TESTS)
add_executable(${LIBRARY_NAME}-UT ${FAKER_UT_SOURCES})

target_link_libraries(${LIBRARY_NAME}-UT PRIVATE gtest_main gmock_main
faker-cxx)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
faker-cxx)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_include_directories(
${LIBRARY_NAME}-UT
PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}
${CMAKE_CURRENT_LIST_DIR})
${LIBRARY_NAME}-UT
PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR})

else()
target_include_directories(
${LIBRARY_NAME}-UT
PRIVATE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}
${CMAKE_CURRENT_LIST_DIR})
${LIBRARY_NAME}-UT
PRIVATE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}
${CMAKE_CURRENT_LIST_DIR})
endif()

add_test(
NAME ${LIBRARY_NAME}-UT
COMMAND ${LIBRARY_NAME}-UT
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
NAME ${LIBRARY_NAME}-UT
COMMAND ${LIBRARY_NAME}-UT
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

target_code_coverage(${LIBRARY_NAME}-UT ALL)
endif()
endif()
4 changes: 3 additions & 1 deletion include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum class Country
Bulgaria,
Moldova,
Lithuania,
Iceland,
};

const std::vector<Country> countries{
Expand All @@ -67,7 +68,7 @@ const std::vector<Country> countries{
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::Bulgaria,
Country::Moldova, Country::Lithuania,
Country::Moldova, Country::Lithuania, Country::Iceland,
};

inline std::string toString(Country country)
Expand Down Expand Up @@ -120,6 +121,7 @@ inline std::string toString(Country country)
{Country::Bulgaria, "Bulgaria"},
{Country::Moldova, "Moldova"},
{Country::Lithuania, "Lithuania"},
{Country::Iceland, "Iceland"},
};

return countryToStringMapping.at(country);
Expand Down
29 changes: 14 additions & 15 deletions src/common/FormatHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@
#include <vector>

#if defined(__APPLE__) || defined(__MINGW32__)
#include <fmt/format.h>
#include <fmt/format.h>
#else
#include <format>
#include <format>
#endif


namespace faker
{
class FormatHelper
{
public:
#if defined(__APPLE__) || defined(__MINGW32__)
#if defined(__APPLE__) || defined(__MINGW32__)
template <typename... Args>
static std::string format(fmt::format_string<Args...> fmt, Args&&... args)
{
return fmt::format(fmt, std::forward<Args>(args)...);
}
#else
template <typename... Args>
static std::string format(std::format_string<Args...> fmt, Args&&... args)
{
return std::format(fmt, std::forward<Args>(args)...);
}
#endif
static std::string format(fmt::format_string<Args...> fmt, Args&&... args)
{
return fmt::format(fmt, std::forward<Args>(args)...);
}
#else
template <typename... Args>
static std::string format(std::format_string<Args...> fmt, Args&&... args)
{
return std::format(fmt, std::forward<Args>(args)...);
}
#endif

static std::string fillTokenValues(const std::string& format,
std::map<std::string, std::function<std::string()>> tokenValueGenerators);
Expand Down
4 changes: 2 additions & 2 deletions src/common/FormatHelperTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ TEST_F(FormatHelperTest, givenTokensWithNotDefinedGenerator_shouldThrow)
ASSERT_THROW(FormatHelper::fillTokenValues(format, dataGeneratorsMapping), errors::TokenGeneratorNotFoundError);
}


TEST_F(FormatHelperTest, shouldFormat) {
TEST_F(FormatHelperTest, shouldFormat)
{
EXPECT_EQ(FormatHelper::format("{}", 1), "1");
EXPECT_EQ(FormatHelper::format("{} {}", "Hello", "World"), "Hello World");
EXPECT_EQ(FormatHelper::format("{0} {1}", "Hello", "World"), "Hello World");
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 @@ -28,6 +28,7 @@
#include "data/greece/GreekPeopleNames.h"
#include "data/Hobbies.h"
#include "data/hungary/HungarianPeopleNames.h"
#include "data/iceland/IcelandicPeopleNames.h"
#include "data/india/IndianPeopleNames.h"
#include "data/iran/PersianPeopleNames.h"
#include "data/ireland/IrishPeopleNames.h"
Expand Down Expand Up @@ -93,7 +94,7 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Belarus, belarusianPeopleNames}, {Country::Estonia, estonianPeopleNames},
{Country::Albania, albanianPeopleNames}, {Country::Iran, persianPeopleNames},
{Country::Bulgaria, bulgarianPeopleNames}, {Country::Moldova, moldovanPeopleNames},
{Country::Lithuania, lithuanianPeopleNames},
{Country::Lithuania, lithuanianPeopleNames}, {Country::Iceland, icelandicPeopleNames},
};

std::string middleNameForCountry(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 @@ -26,6 +26,7 @@
#include "data/greece/GreekPeopleNames.h"
#include "data/Hobbies.h"
#include "data/hungary/HungarianPeopleNames.h"
#include "data/iceland/IcelandicPeopleNames.h"
#include "data/india/IndianPeopleNames.h"
#include "data/iran/PersianPeopleNames.h"
#include "data/ireland/IrishPeopleNames.h"
Expand Down Expand Up @@ -91,7 +92,7 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Belarus, belarusianPeopleNames}, {Country::Estonia, estonianPeopleNames},
{Country::Albania, albanianPeopleNames}, {Country::Iran, persianPeopleNames},
{Country::Bulgaria, bulgarianPeopleNames}, {Country::Moldova, moldovanPeopleNames},
{Country::Lithuania, lithuanianPeopleNames},
{Country::Lithuania, lithuanianPeopleNames}, {Country::Iceland, icelandicPeopleNames},
};

const std::map<Country, std::string> generatedTestName{
Expand All @@ -118,7 +119,7 @@ const std::map<Country, std::string> generatedTestName{
{Country::Belarus, "shouldGenerateBelarusianName"}, {Country::Estonia, "shouldGenerateEstonianName"},
{Country::Albania, "shouldGenerateAlbanianName"}, {Country::Iran, "shouldGeneratePersianName"},
{Country::Bulgaria, "shouldGenerateBulgarianName"}, {Country::Moldova, "shouldGenerateMoldovanName"},
{Country::Lithuania, "shouldGenerateLithuanianName"},
{Country::Lithuania, "shouldGenerateLithuanianName"}, {Country::Iceland, "shouldGenerateIcelandicName"},
};
}

Expand Down
44 changes: 44 additions & 0 deletions src/modules/person/data/iceland/IcelandicFirstNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> icelandicMalesFirstNames = {
"Gunnar", "Einar", "Ragnar", "Karl", "Aron", "Benedikt", "Jon", "Jakob", "Steinar", "Ari",
"Viktor", "Axel", "Alexander", "Anton", "Hannes", "Hermann", "Emil", "Jens", "Hans", "Geir",
"Daniel", "David", "Magnus", "Adam", "Stefan", "Robert", "John", "Piotr", "Elmar", "Georg",
"Albert", "Johann", "Krzysztof", "Erling", "Tomasz", "Marcin", "Jose", "Carlos", "Michael", "Mariusz",
"Alex", "Andrzej", "Bjorn", "Mikael", "Richard", "Jan", "Omar", "Dariusz", "Victor", "Martin",
"Marek", "Kingsley", "Erik", "Oskar", "Tomas", "Pawel", "Johannes", "Jonas", "Mark", "Umar",
"Paulo", "Rafal", "Sebastian", "Ricardo", "Frank", "Joao", "Usman", "James", "Thomas", "Innocent",
"Michal", "Sam", "Miroslaw", "William", "Paul", "Eric", "Henry", "Jaroslaw", "Fernando", "Alfred",
"Matthias", "Andrew", "Luis", "Harald", "Jason", "Peter", "Nils", "Maciej", "Edward", "Kamil",
"Andres", "Roman", "Oliver", "Adolf", "Slawomir", "Artur", "Ifeanyi", "Bruno", "Julius", "Charles",
"Antonio", "Jacek", "Jorge", "Elias", "Wojciech", "Patrick", "George", "Edvard", "Arthur", "Lukasz",
"Marco", "Simon", "Christopher", "Benjamin", "Clement", "Arkadiusz", "Petrea", "Dario", "Chinedu", "Dawid",
"Nuno", "Damian", "Mohamed", "Ivan", "Nicolas", "Mateusz", "Godfrey", "Carl", "Zbigniew", "Philippe",
"Hector", "Uche", "Konrad", "Gabriel", "Mario", "Norbert", "Manuel", "Ismail", "Stephen", "Olivier",
"Felix", "Fred", "Kristofer", "Kevin", "Samuel", "Hugo", "Patryk", "Ashok", "Adrian", "Julio",
"Bent", "Ikechukwu", "Cesar", "Jerzy", "Fritz", "Haruna", "Jonathan"};

const std::vector<std::string> icelandicFemalesFirstNames = {
"Anna", "Helga", "Inga", "Eva", "Linda", "Hanna", "Edda", "Erna", "Sandra",
"Sara", "Karen", "Rakel", "Elsa", "Helena", "Andrea", "Marta", "Elva", "Thelma",
"Agnes", "Alda", "Olga", "Una", "Sonja", "Rebekka", "Gudrun", "Ellen", "Ester",
"Alexandra", "Selma", "Alma", "Stella", "Ana", "Kristin", "Birgitta", "Telma", "Dagmar",
"Klara", "Margret", "Monika", "Magdalena", "Agnieszka", "Lena", "Katarzyna", "Solveig", "Emma",
"Esther", "Tanja", "Barbara", "Mary", "Anita", "Julia", "Vera", "Elin", "Petra",
"Rut", "Sigrun", "Perla", "Helen", "Beata", "Malgorzata", "Heba", "Katrin", "Ella",
"Elma", "Hilda", "Laura", "Asta", "Elisabet", "Johanna", "Juan", "Elzbieta", "Iris",
"Kamilla", "Joanna", "Ewa", "Lea", "Adda", "Amanda", "Inger", "Martha", "Kim",
"Greta", "Natalia", "Dorota", "Nina", "Tara", "Jana", "Sarah", "Rosa", "Ruth",
"Kari", "Tunde", "Rui", "Teresa", "Karolina", "Anne", "Berta", "Maren", "Elizabeth",
"Dora", "Jolanta", "Ann", "Irena", "Renata", "Marzena", "Marie", "Iwona", "Precious",
"Justyna", "Patricia", "Cristina", "Rita", "Sylwia", "Jennifer", "Jenny", "Claudia", "Diana",
"Ingrid", "Miriam", "Astrid", "Stefania", "Emilia", "Hilma", "Irma", "Edyta", "Alice",
"Elena", "Gift", "Dana", "Ida", "Vanessa", "Fanny", "Josephine", "Paulina", "Dennis",
"Alina", "Bozena", "Angela", "Nancy", "Lara", "Jessica",
};
}
25 changes: 25 additions & 0 deletions src/modules/person/data/iceland/IcelandicLastNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> icelandicLastNames = {
"Jónsdóttir", "Jónsson", "Sigurðardóttir", "Guðmundsdóttir", "Guðmundsson", "Sigurðsson", "Gunnarsdóttir", "Gunnarsson", "ólafsson",
"ólafsdóttir", "Magnúsdóttir", "Magnússon", "Einarsson", "Einarsdóttir", "Kristjánsdóttir", "Kristjánsson", "Björnsdóttir", "Stefánsson",
"Jóhannsson", "Jóhannsdóttir", "Björnsson", "Stefánsdóttir", "árnadóttir", "Bjarnason", "Bjarnadóttir", "árnason", "Halldórsson",
"Helgason", "Halldórsdóttir", "Helgadóttir", "Sveinsson", "Ragnarsdóttir", "Kristinsson", "Pétursdóttir", "Pálsson", "Guðjónsdóttir",
"Kristinsdóttir", "Pálsdóttir", "Karlsson", "Guðjónsson", "Pétursson", "þorsteinsson", "þorsteinsdóttir", "Sveinsdóttir", "Ragnarsson",
"óskarsdóttir", "Karlsdóttir", "Haraldsson", "Jóhannesson", "Jóhannesdóttir", "Sigurjónsdóttir", "Birgisson", "Birgisdóttir", "Hauksson",
"Harðardóttir", "þórðardóttir", "ásgeirsdóttir", "Haraldsdóttir", "Jónasdóttir", "Hauksdóttir", "Harðarson", "Jónasson", "Sigurjónsson",
"Kjartansdóttir", "Kjartansson", "ágústsson", "þórðarson", "Arnarson", "Friðriksson", "Baldursdóttir", "Baldursson", "ágústsdóttir",
"Sverrisson", "Hilmarsson", "ásgeirsson", "Friðriksdóttir", "Guðnadóttir", "Ingólfsson", "Guðnason", "Ingólfsdóttir", "Arnardóttir",
"Benediktsdóttir", "Hilmarsdóttir", "Sverrisdóttir", "Valdimarsdóttir", "þórarinsdóttir", "Reynisson", "Benediktsson", "Björgvinsdóttir", "Gunnlaugsson",
"Jonsson", "Gunnlaugsdóttir", "Reynisdóttir", "Aðalsteinsdóttir", "þórisdóttir", "Skúladóttir", "Hafsteinsdóttir", "ómarsdóttir", "Sævarsdóttir",
"Sigurðarson", "Valdimarsson", "þórisson", "Rúnarsdóttir", "Snorrason", "Vilhjálmsdóttir", "þórarinsson", "Hermannsson", "Svavarsdóttir",
"Tryggvason", "Sævarsson", "Garðarsdóttir", "þorvaldsdóttir", "Rúnarsson", "Bragason", "þorvaldsson", "Hannesdóttir", "Vilhjálmsson",
"Björgvinsson", "Bragadóttir", "Egilsson", "Ingvarsdóttir", "Gylfason", "Skúlason", "Hjartardóttir", "Hjartarson", "Ingvarsson",
"Hannesson", "Guðlaugsdóttir", "Lárusdóttir", "ómarsson", "Garðarsson", "Gylfadóttir", "Guðlaugsson", "Grétarsson", "Snorradóttir",
"Aðalsteinsson", "Lárusson", "Tryggvadóttir", "Tómasson", "Jakobsdóttir"};
}
15 changes: 15 additions & 0 deletions src/modules/person/data/iceland/IcelandicPeopleNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include "../NameFormats.h"
#include "../PeopleNames.h"
#include "IcelandicFirstNames.h"
#include "IcelandicLastNames.h"

namespace faker
{
const NameFormats icelandicPersonNameFormats{{"{firstName} {lastName}", 1}};

const PeopleNames icelandicPeopleNames{{icelandicMalesFirstNames, {}, icelandicLastNames, {}, {}},
{icelandicFemalesFirstNames, {}, icelandicLastNames, {}, {}},
icelandicPersonNameFormats};
}

0 comments on commit 3f8df54

Please sign in to comment.