diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b5a46343..6f1c3c012 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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() @@ -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() \ No newline at end of file +endif() diff --git a/include/faker-cxx/types/Country.h b/include/faker-cxx/types/Country.h index a87ebe98d..d8c033cab 100644 --- a/include/faker-cxx/types/Country.h +++ b/include/faker-cxx/types/Country.h @@ -55,6 +55,7 @@ enum class Country Bulgaria, Moldova, Lithuania, + Iceland, }; const std::vector countries{ @@ -67,7 +68,7 @@ const std::vector 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) @@ -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); diff --git a/src/common/FormatHelper.h b/src/common/FormatHelper.h index 0072ba594..036288245 100644 --- a/src/common/FormatHelper.h +++ b/src/common/FormatHelper.h @@ -6,30 +6,29 @@ #include #if defined(__APPLE__) || defined(__MINGW32__) - #include +#include #else - #include +#include #endif - namespace faker { class FormatHelper { public: - #if defined(__APPLE__) || defined(__MINGW32__) +#if defined(__APPLE__) || defined(__MINGW32__) template - static std::string format(fmt::format_string fmt, Args&&... args) - { - return fmt::format(fmt, std::forward(args)...); - } - #else - template - static std::string format(std::format_string fmt, Args&&... args) - { - return std::format(fmt, std::forward(args)...); - } - #endif + static std::string format(fmt::format_string fmt, Args&&... args) + { + return fmt::format(fmt, std::forward(args)...); + } +#else + template + static std::string format(std::format_string fmt, Args&&... args) + { + return std::format(fmt, std::forward(args)...); + } +#endif static std::string fillTokenValues(const std::string& format, std::map> tokenValueGenerators); diff --git a/src/common/FormatHelperTest.cpp b/src/common/FormatHelperTest.cpp index 317a02a1b..8f027a6a0 100644 --- a/src/common/FormatHelperTest.cpp +++ b/src/common/FormatHelperTest.cpp @@ -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"); diff --git a/src/modules/person/Person.cpp b/src/modules/person/Person.cpp index 59732e154..f381f4cea 100644 --- a/src/modules/person/Person.cpp +++ b/src/modules/person/Person.cpp @@ -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" @@ -93,7 +94,7 @@ const std::map 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); diff --git a/src/modules/person/PersonTest.cpp b/src/modules/person/PersonTest.cpp index d9786a916..7fc3cea6b 100644 --- a/src/modules/person/PersonTest.cpp +++ b/src/modules/person/PersonTest.cpp @@ -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" @@ -91,7 +92,7 @@ const std::map 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 generatedTestName{ @@ -118,7 +119,7 @@ const std::map 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"}, }; } diff --git a/src/modules/person/data/iceland/IcelandicFirstNames.h b/src/modules/person/data/iceland/IcelandicFirstNames.h new file mode 100644 index 000000000..58850fb83 --- /dev/null +++ b/src/modules/person/data/iceland/IcelandicFirstNames.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector 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 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", +}; +} diff --git a/src/modules/person/data/iceland/IcelandicLastNames.h b/src/modules/person/data/iceland/IcelandicLastNames.h new file mode 100644 index 000000000..e50b445b9 --- /dev/null +++ b/src/modules/person/data/iceland/IcelandicLastNames.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector 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"}; +} diff --git a/src/modules/person/data/iceland/IcelandicPeopleNames.h b/src/modules/person/data/iceland/IcelandicPeopleNames.h new file mode 100644 index 000000000..0a2846e3d --- /dev/null +++ b/src/modules/person/data/iceland/IcelandicPeopleNames.h @@ -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}; +}