diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cf71ddcb..73f507146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,9 @@ target_include_directories( INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include" PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include") -if(APPLE) +if(APPLE OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION + VERSION_LESS 12)) + add_subdirectory(externals/fmt) set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include") target_link_libraries(${LIBRARY_NAME} PRIVATE fmt) @@ -140,7 +142,10 @@ if(BUILD_FAKER_TESTS) target_link_libraries(${LIBRARY_NAME}-UT PRIVATE gtest_main gmock_main faker-cxx) - if(APPLE) + if(APPLE OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12)) + + target_link_libraries(${LIBRARY_NAME}-UT PRIVATE fmt) target_include_directories( ${LIBRARY_NAME}-UT PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} diff --git a/include/faker-cxx/Internet.h b/include/faker-cxx/Internet.h index 70aa03edc..af90ca453 100644 --- a/include/faker-cxx/Internet.h +++ b/include/faker-cxx/Internet.h @@ -3,6 +3,7 @@ #include #include #include + #include "types/Country.h" #include "types/EmojiType.h" @@ -57,8 +58,7 @@ class Internet * @endcode */ static std::string username(std::optional firstName = std::nullopt, - std::optional lastName = std::nullopt, - Country country = Country::Usa); + std::optional lastName = std::nullopt, Country country = Country::Usa); /** * @brief Generates an email address using the given person's name as base. diff --git a/include/faker-cxx/types/AddressCountry.h b/include/faker-cxx/types/AddressCountry.h index 23aa2ece2..fe04b57f6 100644 --- a/include/faker-cxx/types/AddressCountry.h +++ b/include/faker-cxx/types/AddressCountry.h @@ -22,7 +22,8 @@ namespace faker Denmark, Spain, Brazil, - Finland + Finland, + Estonia }; const std::vector addressCountries{ diff --git a/src/common/FormatHelper.h b/src/common/FormatHelper.h index 036288245..52fd9eaf9 100644 --- a/src/common/FormatHelper.h +++ b/src/common/FormatHelper.h @@ -5,7 +5,7 @@ #include #include -#if defined(__APPLE__) || defined(__MINGW32__) +#if defined(__APPLE__) || defined(__MINGW32__) || (defined(__GNUC__) && (__GNUC__ < 12) && !defined(__clang__)) #include #else #include @@ -16,7 +16,7 @@ namespace faker class FormatHelper { public: -#if defined(__APPLE__) || defined(__MINGW32__) +#if defined(__APPLE__) || defined(__MINGW32__) || (defined(__GNUC__) && (__GNUC__ < 12) && !defined(__clang__)) template static std::string format(fmt::format_string fmt, Args&&... args) { diff --git a/src/modules/location/Location.cpp b/src/modules/location/Location.cpp index af7d4b0c4..8ac718bf7 100644 --- a/src/modules/location/Location.cpp +++ b/src/modules/location/Location.cpp @@ -24,6 +24,7 @@ #include "faker-cxx/String.h" #include "data/india/IndiaAddresses.h" #include "data/denmark/DenmarkAddresses.h" +#include "data/estonia/EstoniaAddresses.h" namespace faker { @@ -37,6 +38,7 @@ namespace faker {AddressCountry::Australia, australiaAddresses}, {AddressCountry::India, indiaAddresses}, {AddressCountry::Denmark, denmarkAddresses}, {AddressCountry::Spain, spainAddresses}, {AddressCountry::Brazil, brazilAddresses}, {AddressCountry::Finland, finlandAddresses}, + {AddressCountry::Estonia, estoniaAddresses}, }; const std::map countryAddressToCountryMapping{ @@ -47,6 +49,7 @@ namespace faker {AddressCountry::Australia, Country::Australia}, {AddressCountry::India, Country::India}, {AddressCountry::Denmark, Country::Denmark}, {AddressCountry::Spain, Country::Spain}, {AddressCountry::Brazil, Country::Brazil}, {AddressCountry::Finland, Country::Finland}, + {AddressCountry::Estonia, Country::Estonia}, }; } diff --git a/src/modules/location/LocationTest.cpp b/src/modules/location/LocationTest.cpp index ab5b71995..d2d717c9d 100644 --- a/src/modules/location/LocationTest.cpp +++ b/src/modules/location/LocationTest.cpp @@ -21,6 +21,8 @@ #include "../person/data/australia/AustralianLastNames.h" #include "../person/data/finland/FinnishFirstNames.h" #include "../person/data/finland/FinnishLastNames.h" +#include "../person/data/estonia/EstonianFirstNames.h" +#include "../person/data/estonia/EstonianLastNames.h" #include "../string/data/Characters.h" #include "data/Countries.h" #include "data/CountryAddresses.h" @@ -40,6 +42,7 @@ #include "data/spain/SpainAddresses.h" #include "data/brazil/BrazilAddresses.h" #include "data/finland/FinlandAddresses.h" +#include "data/estonia/EstoniaAddresses.h" using namespace ::testing; using namespace faker; @@ -54,6 +57,7 @@ namespace {AddressCountry::Australia, australiaAddresses}, {AddressCountry::India, indiaAddresses}, {AddressCountry::Denmark, denmarkAddresses}, {AddressCountry::Spain, spainAddresses}, {AddressCountry::Brazil, brazilAddresses}, {AddressCountry::Finland, finlandAddresses}, + {AddressCountry::Estonia, estoniaAddresses}, }; const std::map generatedTestName{ @@ -71,6 +75,7 @@ namespace {AddressCountry::Spain, "shouldGenerateSpainAddress"}, {AddressCountry::Brazil, "shouldGenerateBrazilAddress"}, {AddressCountry::Finland, "shouldGenerateFinlandAddress"}, + {AddressCountry::Estonia, "shouldGenerateEstoniaAddress"}, }; } @@ -701,7 +706,8 @@ TEST_F(LocationTest, shouldGenerateIndiaStreetAddress) TEST_F(LocationTest, shouldGenerateDenmarkStreet) { const auto generatedStreet = Location::street(AddressCountry::Denmark); - + + ASSERT_TRUE(std::ranges::any_of(denmarkStreetNames, [&generatedStreet](const std::string& streetName) { return streetName == generatedStreet; })); } @@ -790,4 +796,21 @@ TEST_F(LocationTest, shouldGenerateFinlandStreetAddress) { return generatedStreetAddress.find(firstName) != std::string::npos; }) || std::ranges::any_of(lastNames, [&generatedStreetAddress](const std::string& lastName) { return generatedStreetAddress.find(lastName) != std::string::npos; })); -} \ No newline at end of file +} + + +TEST_F(LocationTest, shouldGenerateEstoniaStreet) +{ + const auto generatedStreet = Location::street(AddressCountry::Estonia); + + ASSERT_TRUE(std::ranges::any_of(estoniaStreetNames, [&generatedStreet](const std::string& streetName) + { return generatedStreet.find(streetName) != std::string::npos; })); +} + +TEST_F(LocationTest, shouldGenerateEstoniaStreetAddress) +{ + const auto generatedStreetAddress = Location::streetAddress(AddressCountry::Estonia); + + ASSERT_TRUE(std::ranges::any_of(estoniaStreetNames, [&generatedStreetAddress](const std::string& streetName) + { return generatedStreetAddress.find(streetName) != std::string::npos; })); +} diff --git a/src/modules/location/data/estonia/EstoniaAddresses.h b/src/modules/location/data/estonia/EstoniaAddresses.h new file mode 100644 index 000000000..04f068007 --- /dev/null +++ b/src/modules/location/data/estonia/EstoniaAddresses.h @@ -0,0 +1,35 @@ +#pragma once + +#include "../CountryAddresses.h" +#include "EstoniaCities.h" +#include "EstoniaCounties.h" +#include "EstoniaStreetNames.h" +#include "EstoniaStreetSuffixes.h" + +namespace faker { + +const std::string estoniaZipCodeFormat{"#####"}; + +const std::vector estoniaAddressFormats{"{street} {buildingNumber}"}; + +const std::vector estoniaBuildingNumberFormats{"###", "##", "#"}; + +const std::vector estoniaStreetFormats{"{streetName} {streetSuffix}"}; + +const std::vector estoniaCityFormats{"{cityName}"}; + +const CountryAddresses estoniaAddresses{estoniaZipCodeFormat, + estoniaAddressFormats, + {}, + estoniaStreetFormats, + {}, + estoniaStreetNames, + estoniaStreetSuffixes, + estoniaBuildingNumberFormats, + estoniaCityFormats, + {}, + estoniaCities, + {}, + {}, + estoniaCounties}; +} \ No newline at end of file diff --git a/src/modules/location/data/estonia/EstoniaCities.h b/src/modules/location/data/estonia/EstoniaCities.h new file mode 100644 index 000000000..906559a67 --- /dev/null +++ b/src/modules/location/data/estonia/EstoniaCities.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector estoniaCities{ + "Tallinn", + "Tartu", + "Narva", + "Pärnu", + "Kohtla-Järve", + +}; + +} \ No newline at end of file diff --git a/src/modules/location/data/estonia/EstoniaCounties.h b/src/modules/location/data/estonia/EstoniaCounties.h new file mode 100644 index 000000000..97b210121 --- /dev/null +++ b/src/modules/location/data/estonia/EstoniaCounties.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector estoniaCounties { + + "Harju", + "Hiiu", + "Ida-Viru", + "Jõgeva", + "Järva", + "Lääne", + "Lääne-Viru", + "Põlva", + "Pärnu", + "Rapla", + "Saare", + "Tartu", + "Valga", + "Viljandi", + "Võru", + +}; + +} \ No newline at end of file diff --git a/src/modules/location/data/estonia/EstoniaStreetNames.h b/src/modules/location/data/estonia/EstoniaStreetNames.h new file mode 100644 index 000000000..650f3769e --- /dev/null +++ b/src/modules/location/data/estonia/EstoniaStreetNames.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector estoniaStreetNames{ +"Laagna", +"Punane", +"Paepargi", +"Pae", +"Peterburi", +"Valukoja", +"Betooni", +"Sõpruse", +"Mustamäe", +"Tuisu", +"Külmallika", +"Tammi", +"Koore", +"Kuubi", +"Okka", +"Vaba", +"Tähe", +"Õnne", +"Aleksandri", +"Kalevi", +"Turu", +"Tähe", +"Lina", +"Õnne", +"Era", +"Vanemuise", +"Tiigi", +"Tiigi", +"Juhan Liivi", +"K. A. Hermanni", +"Veski", +}; + +} \ No newline at end of file diff --git a/src/modules/location/data/estonia/EstoniaStreetSuffixes.h b/src/modules/location/data/estonia/EstoniaStreetSuffixes.h new file mode 100644 index 000000000..05765fe42 --- /dev/null +++ b/src/modules/location/data/estonia/EstoniaStreetSuffixes.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector estoniaStreetSuffixes { + "Tänav", + "tn", + "Tee", + "Allee", + "Plats", + "Käik", + "Põik", +}; + +} \ No newline at end of file