Skip to content

Commit

Permalink
debuged the added test case failuure
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jomorodi committed Jan 17, 2024
1 parent 3dc91c9 commit 5cc5fa9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/location/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<AddressCountry, Country> countryAddressToCountryMapping{
Expand All @@ -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},
};
}

Expand Down
9 changes: 5 additions & 4 deletions src/modules/location/LocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }));
}
Expand Down Expand Up @@ -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; }));
}
2 changes: 1 addition & 1 deletion src/modules/location/data/estonia/EstoniaAddresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const CountryAddresses estoniaAddresses{estoniaZipCodeFormat,
{},
estoniaStreetFormats,
{},
{},
estoniaStreetNames,
estoniaStreetSuffixes,
estoniaBuildingNumberFormats,
estoniaCityFormats,
Expand Down
10 changes: 5 additions & 5 deletions src/modules/location/data/estonia/EstoniaStreetNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
namespace faker
{
const std::vector<std::string> 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",
Expand Down

0 comments on commit 5cc5fa9

Please sign in to comment.