Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue:446 Add location address data for Serbia. #533

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/faker-cxx/Location.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum class AddressCountry
Romania,
Latvia,
Nepal,
Belgium
Belgium,
Serbia
};

class Location
Expand Down
5 changes: 4 additions & 1 deletion src/modules/location/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "data/poland/PolandAddresses.h"
#include "data/romania/RomaniaAddresses.h"
#include "data/russia/RussiaAddresses.h"
#include "data/serbia/SerbiaAddresses.h"
#include "data/spain/SpainAddresses.h"
#include "data/TimeZones.h"
#include "data/ukraine/UkraineAddresses.h"
Expand Down Expand Up @@ -54,7 +55,8 @@ const std::map<AddressCountry, CountryAddresses> countryToCountryAddressesMappin
{AddressCountry::Latvia, latviaAddresses},
{AddressCountry::Nepal, nepalAddresses},
{AddressCountry::Belgium, belgiumAddresses},
};
{AddressCountry::Serbia, serbiaAddresses},
};

const std::map<AddressCountry, Country> countryAddressToCountryMapping{
{AddressCountry::Usa, Country::Usa},
Expand All @@ -76,6 +78,7 @@ const std::map<AddressCountry, Country> countryAddressToCountryMapping{
{AddressCountry::Latvia, Country::Latvia},
{AddressCountry::Nepal, Country::Nepal},
{AddressCountry::Belgium, Country::Belgium},
{AddressCountry::Serbia, Country::Serbia},
};
}

Expand Down
21 changes: 20 additions & 1 deletion src/modules/location/LocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "data/poland/PolandAddresses.h"
#include "data/romania/RomaniaAddresses.h"
#include "data/russia/RussiaAddresses.h"
#include "data/serbia/SerbiaAddresses.h"
#include "data/spain/SpainAddresses.h"
#include "data/TimeZones.h"
#include "data/ukraine/UkraineAddresses.h"
Expand All @@ -56,7 +57,7 @@ const std::vector<AddressCountry> addressCountries{
AddressCountry::Ukraine, AddressCountry::Italy, AddressCountry::Germany, AddressCountry::Czech,
AddressCountry::India, AddressCountry::Denmark, AddressCountry::Australia, AddressCountry::Spain,
AddressCountry::Brazil, AddressCountry::Finland, AddressCountry::Estonia, AddressCountry::Romania,
AddressCountry::Latvia};
AddressCountry::Latvia, AddressCountry::Serbia };

const std::map<AddressCountry, CountryAddresses> countryToCountryAddressesMapping{
{AddressCountry::Usa, usaAddresses},
Expand All @@ -78,6 +79,7 @@ const std::map<AddressCountry, CountryAddresses> countryToCountryAddressesMappin
{AddressCountry::Latvia, latviaAddresses},
{AddressCountry::Nepal, nepalAddresses},
{AddressCountry::Belgium, belgiumAddresses},
{AddressCountry::Serbia, serbiaAddresses},
};

const std::map<AddressCountry, std::string> generatedTestName{
Expand All @@ -100,6 +102,7 @@ const std::map<AddressCountry, std::string> generatedTestName{
{AddressCountry::Latvia, "shouldGenerateLatviaAddress"},
{AddressCountry::Nepal, "shouldGenerateNepalAddress"},
{AddressCountry::Belgium, "shouldGenerateBelgiumAddress"},
{AddressCountry::Serbia, "shouldGenerateSerbiaAddress"},
};
}

Expand Down Expand Up @@ -937,3 +940,19 @@ TEST_F(LocationTest, shouldGenerateBelgiumStreetAddress)
ASSERT_TRUE(std::ranges::any_of(belgiumStreetSuffixes, [&generatedStreetSuffix](const std::string& streetSuffix)
{ return streetSuffix == generatedStreetSuffix; }));
}

TEST_F(LocationTest, shouldGenerateSerbiaStreet)
{
const auto generatedStreet = Location::street(AddressCountry::Serbia);

ASSERT_TRUE(std::ranges::any_of(serbiaStreetNames, [&generatedStreet](const std::string& streetName)
{ return streetName == generatedStreet; }));
}

TEST_F(LocationTest, shouldGenerateSerbiaStreetAddress)
{
const auto generatedStreetAddress = Location::streetAddress(AddressCountry::Serbia);

ASSERT_TRUE(std::ranges::any_of(serbiaStreetNames, [&generatedStreetAddress](const std::string& streetName)
{ return generatedStreetAddress.find(streetName) != std::string::npos; }));
}
40 changes: 40 additions & 0 deletions src/modules/location/data/serbia/SerbiaAddresses.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include "../CountryAddresses.h"
#include "SerbiaCities.h"
#include "SerbiaStates.h"
#include "SerbiaStreetNames.h"

namespace faker
{
const std::string serbiaZipCodeFormat{"#####"};

const std::vector<std::string> serbiaAddressFormats{"{buildingNumber} {street}"};

const std::vector<std::string> serbiaSecondaryAddressFormats{"Sprat #", "Stan ##"};

const std::vector<std::string> serbiaBuildingNumberFormats{
"#",
"##",
"###",
};

const std::vector<std::string> serbiaStreetFormats{"{streetName}"};

const std::vector<std::string> serbiaCityFormats{"{cityName}"};

const CountryAddresses serbiaAddresses{serbiaZipCodeFormat,
serbiaAddressFormats,
serbiaSecondaryAddressFormats,
serbiaStreetFormats,
{},
serbiaStreetNames,
{},
serbiaBuildingNumberFormats,
serbiaCityFormats,
{},
serbiaCities,
{},
serbiaStates,
{}};
}
37 changes: 37 additions & 0 deletions src/modules/location/data/serbia/SerbiaCities.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> serbiaCities = {
"Beograd",
"Bor",
"Jagodina",
"Kikinda",
"Kraljevo",
"Kruševac",
"Leskovac",
"Niš",
"Novi Pazar",
"Novi Sad",
"Pančevo",
"Paraćin",
"Pirot",
"Požarevac",
"Prokuplje",
"Smederevo",
"Sombor",
"Sopot",
"Sremska Mitrovica",
"Subotica",
"Užice",
"Vranje",
"Vršac",
"Zaječar",
"Zrenjanjin",
"Čačak",
"Šabac",
};
}
40 changes: 40 additions & 0 deletions src/modules/location/data/serbia/SerbiaStates.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> serbiaStates = {
"Borski okrug",
"Braničevski okrug",
"Grad Beograd",
"Zaječarski okrug",
"Zapadnobački okrug",
"Zlatiborski okrug",
"Jablanički okrug",
"Južnobanatski okrug",
"Južnobački okrug",
"Kolubarski okrug",
"Kosovski okrug",
"Kosovskomitrovački okrug",
"Kosovskopomoravski okrug",
"Mačvanski okrug",
"Moravički okrug",
"Nišavski okrug",
"Pećki okrug",
"Pirotski okrug",
"Podunavski okrug",
"Pomoravski okrug",
"Prizrenski okrug",
"Pčinjski okrug",
"Rasinski okrug",
"Raški okrug",
"Severnobanatski okrug",
"Severnobački okrug",
"Srednjobanatski okrug",
"Sremski okrug",
"Toplički okrug",
"Šumadijski okrug",
};
}
Loading
Loading