From 5cc5fa94f05e1a3fb845cae5d1f80bd7d4e04b7e Mon Sep 17 00:00:00 2001 From: jomorodi Date: Wed, 17 Jan 2024 03:50:50 +0200 Subject: [PATCH] debuged the added test case failuure modified the test case, included the proper headers in location source file modified CMake list by removing the dependency introduced inadverently for g++ version greater than 10 modified the EstoniaStreetNames by removing street suffixes finally corrected error in arguement passed to the estonianadresses object --- CMakeLists.txt | 5 +++-- src/modules/location/Location.cpp | 3 +++ src/modules/location/LocationTest.cpp | 9 +++++---- src/modules/location/data/estonia/EstoniaAddresses.h | 2 +- src/modules/location/data/estonia/EstoniaStreetNames.h | 10 +++++----- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ae8cf244..73f507146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,12 +139,13 @@ if(BUILD_FAKER_TESTS) add_executable(${LIBRARY_NAME}-UT ${FAKER_UT_SOURCES}) - target_link_libraries(${LIBRARY_NAME}-UT PRIVATE fmt gtest_main gmock_main + target_link_libraries(${LIBRARY_NAME}-UT PRIVATE gtest_main gmock_main faker-cxx) if(APPLE OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12)) - message(STATUS , "format library is included") + + target_link_libraries(${LIBRARY_NAME}-UT PRIVATE fmt) target_include_directories( ${LIBRARY_NAME}-UT PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} 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 f99c82920..d2d717c9d 100644 --- a/src/modules/location/LocationTest.cpp +++ b/src/modules/location/LocationTest.cpp @@ -706,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; })); } @@ -801,15 +802,15 @@ TEST_F(LocationTest, shouldGenerateFinlandStreetAddress) TEST_F(LocationTest, shouldGenerateEstoniaStreet) { const auto generatedStreet = Location::street(AddressCountry::Estonia); - + ASSERT_TRUE(std::ranges::any_of(estoniaStreetNames, [&generatedStreet](const std::string& streetName) - { return streetName == generatedStreet; })); + { 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 index a1f1938c2..04f068007 100644 --- a/src/modules/location/data/estonia/EstoniaAddresses.h +++ b/src/modules/location/data/estonia/EstoniaAddresses.h @@ -23,7 +23,7 @@ const CountryAddresses estoniaAddresses{estoniaZipCodeFormat, {}, estoniaStreetFormats, {}, - {}, + estoniaStreetNames, estoniaStreetSuffixes, estoniaBuildingNumberFormats, estoniaCityFormats, diff --git a/src/modules/location/data/estonia/EstoniaStreetNames.h b/src/modules/location/data/estonia/EstoniaStreetNames.h index e030a34b1..650f3769e 100644 --- a/src/modules/location/data/estonia/EstoniaStreetNames.h +++ b/src/modules/location/data/estonia/EstoniaStreetNames.h @@ -6,18 +6,18 @@ namespace faker { const std::vector estoniaStreetNames{ -"Laagna tee", +"Laagna", "Punane", "Paepargi", "Pae", -"Peterburi tee", +"Peterburi", "Valukoja", "Betooni", -"Sõpruse pst", -"Mustamäe tee", +"Sõpruse", +"Mustamäe", "Tuisu", "Külmallika", -"Tammi tee", +"Tammi", "Koore", "Kuubi", "Okka",