From 8899000ce2855fc29dc7cba6cd51ccaed5aa6567 Mon Sep 17 00:00:00 2001 From: Krupal J S Bhat <56032256+krupalbhat@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:41:07 +0530 Subject: [PATCH] Added location addresses data from Belgium (#531) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added location addresses data from Belgium * resolved the failing tests related to Belgium street addresses. --------- Co-authored-by: Michał Cieślar --- include/faker-cxx/Location.h | 3 +- src/modules/location/Location.cpp | 6 +- src/modules/location/LocationTest.cpp | 39 +++ .../location/data/belgium/BelgiumAddresses.h | 37 +++ .../location/data/belgium/BelgiumCities.h | 270 ++++++++++++++++++ .../location/data/belgium/BelgiumStates.h | 20 ++ .../data/belgium/BelgiumStreetPrefixes.h | 26 ++ .../data/belgium/BelgiumStreetSuffixes.h | 219 ++++++++++++++ 8 files changed, 618 insertions(+), 2 deletions(-) create mode 100644 src/modules/location/data/belgium/BelgiumAddresses.h create mode 100644 src/modules/location/data/belgium/BelgiumCities.h create mode 100644 src/modules/location/data/belgium/BelgiumStates.h create mode 100644 src/modules/location/data/belgium/BelgiumStreetPrefixes.h create mode 100644 src/modules/location/data/belgium/BelgiumStreetSuffixes.h diff --git a/include/faker-cxx/Location.h b/include/faker-cxx/Location.h index c7394aa14..5dc5e155c 100644 --- a/include/faker-cxx/Location.h +++ b/include/faker-cxx/Location.h @@ -25,7 +25,8 @@ enum class AddressCountry Estonia, Romania, Latvia, - Nepal + Nepal, + Belgium }; class Location diff --git a/src/modules/location/Location.cpp b/src/modules/location/Location.cpp index b692a9d1c..7b43e43ca 100644 --- a/src/modules/location/Location.cpp +++ b/src/modules/location/Location.cpp @@ -7,6 +7,7 @@ #include "../../common/mappers/precisionMapper/PrecisionMapper.h" #include "data/australia/AustraliaAddresses.h" #include "data/brazil/BrazilAddresses.h" +#include "data/belgium/BelgiumAddresses.h" #include "data/Countries.h" #include "data/czech/CzechAddresses.h" #include "data/denmark/DenmarkAddresses.h" @@ -51,7 +52,9 @@ const std::map countryToCountryAddressesMappin {AddressCountry::Estonia, estoniaAddresses}, {AddressCountry::Romania, romaniaAddresses}, {AddressCountry::Latvia, latviaAddresses}, - {AddressCountry::Nepal, nepalAddresses},}; + {AddressCountry::Nepal, nepalAddresses}, + {AddressCountry::Belgium, belgiumAddresses}, + }; const std::map countryAddressToCountryMapping{ {AddressCountry::Usa, Country::Usa}, @@ -72,6 +75,7 @@ const std::map countryAddressToCountryMapping{ {AddressCountry::Romania, Country::Romania}, {AddressCountry::Latvia, Country::Latvia}, {AddressCountry::Nepal, Country::Nepal}, + {AddressCountry::Belgium, Country::Belgium}, }; } diff --git a/src/modules/location/LocationTest.cpp b/src/modules/location/LocationTest.cpp index c9c123d5a..9491162b6 100644 --- a/src/modules/location/LocationTest.cpp +++ b/src/modules/location/LocationTest.cpp @@ -26,6 +26,7 @@ #include "data/brazil/BrazilAddresses.h" #include "data/Countries.h" #include "data/CountryAddresses.h" +#include "data/belgium/BelgiumAddresses.h" #include "data/czech/CzechAddresses.h" #include "data/denmark/DenmarkAddresses.h" #include "data/Directions.h" @@ -76,6 +77,7 @@ const std::map countryToCountryAddressesMappin {AddressCountry::Romania, romaniaAddresses}, {AddressCountry::Latvia, latviaAddresses}, {AddressCountry::Nepal, nepalAddresses}, + {AddressCountry::Belgium, belgiumAddresses}, }; const std::map generatedTestName{ @@ -97,6 +99,7 @@ const std::map generatedTestName{ {AddressCountry::Romania, "shouldGenerateRomaniaAddress"}, {AddressCountry::Latvia, "shouldGenerateLatviaAddress"}, {AddressCountry::Nepal, "shouldGenerateNepalAddress"}, + {AddressCountry::Belgium, "shouldGenerateBelgiumAddress"}, }; } @@ -898,3 +901,39 @@ TEST_F(LocationTest, shouldGenerateNepalStreetAddress) ASSERT_TRUE(std::ranges::any_of(nepalStreetSuffixes, [&generatedStreetSuffix](const std::string& streetSuffix) { return streetSuffix == generatedStreetSuffix; })); } + +TEST_F(LocationTest, shouldGenerateBelgiumStreet) +{ + const auto generatedStreet = Location::street(AddressCountry::Belgium); + + const auto generatedStreetElements = StringHelper::split(generatedStreet, " "); + + const auto& generatedStreetPrefix = generatedStreetElements[0]; + const auto& generatedStreetSuffix = + StringHelper::join({generatedStreetElements.begin() + 1, generatedStreetElements.end()}); + + ASSERT_LT(generatedStreetElements.size(), 6); + ASSERT_TRUE(std::ranges::any_of(belgiumStreetPrefixes, [&generatedStreetPrefix](const std::string& streetPrefix) + { return streetPrefix == generatedStreetPrefix; })); + ASSERT_TRUE(std::ranges::any_of(belgiumStreetSuffixes, [&generatedStreetSuffix](const std::string& streetSuffix) + { return streetSuffix == generatedStreetSuffix; })); +} + +TEST_F(LocationTest, shouldGenerateBelgiumStreetAddress) +{ + const auto generatedStreetAddress = Location::streetAddress(AddressCountry::Belgium); + + const auto generatedStreetAddressElements = StringHelper::split(generatedStreetAddress, " "); + + const auto& generatedBuildingNumber = generatedStreetAddressElements[0]; + const auto& generatedStreetPrefix = generatedStreetAddressElements[1]; + const auto& generatedStreetSuffix = + StringHelper::join({generatedStreetAddressElements.begin() + 2, generatedStreetAddressElements.end()}); + + ASSERT_GE(generatedStreetAddressElements.size(), 3); + ASSERT_TRUE(!generatedBuildingNumber.empty() && generatedBuildingNumber.size() <= 7); + ASSERT_TRUE(std::ranges::any_of(belgiumStreetPrefixes, [&generatedStreetPrefix](const std::string& streetPrefix) + { return streetPrefix == generatedStreetPrefix; })); + ASSERT_TRUE(std::ranges::any_of(belgiumStreetSuffixes, [&generatedStreetSuffix](const std::string& streetSuffix) + { return streetSuffix == generatedStreetSuffix; })); +} diff --git a/src/modules/location/data/belgium/BelgiumAddresses.h b/src/modules/location/data/belgium/BelgiumAddresses.h new file mode 100644 index 000000000..8ba02ab87 --- /dev/null +++ b/src/modules/location/data/belgium/BelgiumAddresses.h @@ -0,0 +1,37 @@ +#pragma once + +#include "../CountryAddresses.h" +#include "BelgiumCities.h" +#include "BelgiumStates.h" +#include "BelgiumStreetSuffixes.h" +#include "BelgiumStreetPrefixes.h" + +namespace faker +{ +const std::string belgiumZipCodeFormat{"####"}; + +const std::vector belgiumAddressFormats{"{buildingNumber} {street}"}; + +const std::vector belgiumSecondaryAddressFormats{"Apt. ###", "Étage #"}; + +const std::vector belgiumBuildingNumberFormats{ "#", "##", "###", "###a", "###b", "###c", "###/2",}; + +const std::vector belgiumStreetFormats{"{streetPrefix} {streetSuffix}"}; + +const std::vector belgiumCityFormats{"{cityName}"}; + +const CountryAddresses belgiumAddresses{belgiumZipCodeFormat, + belgiumAddressFormats, + belgiumSecondaryAddressFormats, + belgiumStreetFormats, + belgiumStreetPrefixes, + {}, + belgiumStreetSuffixes, + belgiumBuildingNumberFormats, + belgiumCityFormats, + {}, + belgiumCities, + {}, + belgiumStates, + {}}; +} diff --git a/src/modules/location/data/belgium/BelgiumCities.h b/src/modules/location/data/belgium/BelgiumCities.h new file mode 100644 index 000000000..39f6b812a --- /dev/null +++ b/src/modules/location/data/belgium/BelgiumCities.h @@ -0,0 +1,270 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector belgiumCities = {"Amblève", + "Bullange", + "Burg-Reuland", + "Butgenbach", + "Eupen", + "La Calamine", + "Lontzen", + "Raeren", + "Saint-Vith", + "Aiseau-Presles", + "Amay", + "Andenne", + "Anderlues", + "Anhée", + "Ans", + "Anthisnes", + "Antoing", + "Arlon", + "Assesse", + "Ath", + "Attert", + "Aubange", + "Aubel", + "Awans", + "Aywaille", + "Baelen", + "Bassenge", + "Bastogne", + "Beaumont", + "Beauraing", + "Beauvechain", + "Beloeil", + "Berloz", + "Bernissart", + "Bertogne", + "Bertrix", + "Beyne-Heusay", + "Bièvre", + "Binche", + "Blégny", + "Bouillon", + "Boussu", + "Braine-l\'Alleud", + "Braine-le-Château", + "Braine-le-Comte", + "Braives", + "Brugelette", + "Brunehaut", + "Burdinne", + "Celles", + "Cerfontaine", + "Chapelle-lez-Herlaimont", + "Charleroi", + "Chastre", + "Châtelet", + "Chaudfontaine", + "Chaumont-Gistoux", + "Chièvres", + "Chimay", + "Chiny", + "Ciney", + "Clavier", + "Colfontaine", + "Comblain-au-Pont", + "Comines-Warneton", + "Courcelles", + "Court-Saint-Etienne", + "Couvin", + "Crisnée", + "Dalhem", + "Daverdisse", + "Dinant", + "Dison", + "Doische", + "Donceel", + "Dour", + "Durbuy", + "Ecaussinnes", + "Eghezée", + "Ellezelles", + "Enghien", + "Engis", + "Erezée", + "Erquelinnes", + "Esneux", + "Estaimpuis", + "Estinnes", + "Etalle", + "Faimes", + "Farciennes", + "Fauvillers", + "Fernelmont", + "Ferrières", + "Fexhe-le-Haut-Clocher", + "Flémalle", + "Fléron", + "Fleurus", + "Flobecq", + "Floreffe", + "Florennes", + "Florenville", + "Fontaine-l\'Evêque", + "Fosses-la-Ville", + "Frameries", + "Frasnes-lez-Anvaing", + "Froidchapelle", + "Gedinne", + "Geer", + "Gembloux", + "Genappe", + "Gerpinnes", + "Gesves", + "Gouvy", + "Grâce-Hollogne", + "Grez-Doiceau", + "Habay", + "Hamoir", + "Hamois", + "Ham-sur-Heure-Nalinnes", + "Hannut", + "Hastière", + "Havelange", + "Hélécine", + "Hensies", + "Herbeumont", + "Héron", + "Herstal", + "Herve", + "Honnelles", + "Hotton", + "Houffalize", + "Houyet", + "Huy", + "Incourt", + "Ittre", + "Jalhay", + "Jemeppe-sur-Sambre", + "Jodoigne", + "Juprelle", + "Jurbise", + "La Bruyère", + "La Hulpe", + "La Louvière", + "La Roche-en-Ardenne", + "Lasne", + "Le Roeulx", + "Léglise", + "Lens", + "Les Bons Villers", + "Lessines", + "Leuze-en-Hainaut", + "Libin", + "Libramont-Chevigny", + "Liège", + "Lierneux", + "Limbourg", + "Lincent", + "Lobbes", + "Malmedy", + "Manage", + "Manhay", + "Marche-en-Famenne", + "Marchin", + "Martelange", + "Meix-devant-Virton", + "Merbes-le-Château", + "Messancy", + "Mettet", + "Modave", + "Momignies", + "Mons", + "Mont-de-l\'Enclus", + "Montigny-le-Tilleul", + "Mont-Saint-Guibert", + "Morlanwelz", + "Mouscron", + "Musson", + "Namur", + "Nandrin", + "Nassogne", + "Neufchâteau", + "Neupré", + "Nivelles", + "Ohey", + "Olne", + "Onhaye", + "Oreye", + "Orp-Jauche", + "Ottignies-Louvain-la-Neuve", + "Ouffet", + "Oupeye", + "Paliseul", + "Pecq", + "Pepinster", + "Péruwelz", + "Perwez", + "Philippeville", + "Plombières", + "Pont-à-celles", + "Profondeville", + "Quaregnon", + "Quévy", + "Quiévrain", + "Ramillies", + "Rebecq", + "Remicourt", + "Rendeux", + "Rixensart", + "Rochefort", + "Rouvroy", + "Rumes", + "Sainte-Ode", + "Saint-Georges-sur-Meuse", + "Saint-Ghislain", + "Saint-Hubert", + "Saint-Léger", + "Saint-Nicolas", + "Sambreville", + "Seneffe", + "Seraing", + "Silly", + "Sivry-Rance", + "Soignies", + "Sombreffe", + "Somme-Leuze", + "Soumagne", + "Spa", + "Sprimont", + "Stavelot", + "Stoumont", + "Tellin", + "Tenneville", + "Theux", + "Thimister-Clermont", + "Thuin", + "Tinlot", + "Tintigny", + "Tournai", + "Trois-Ponts", + "Trooz", + "Tubize", + "Vaux-sur-Sûre", + "Verlaine", + "Verviers", + "Vielsalm", + "Villers-la-Ville", + "Villers-le-Bouillet", + "Viroinval", + "Virton", + "Visé", + "Vresse-sur-Semois", + "Waimes", + "Walcourt", + "Walhain", + "Wanze", + "Waremme", + "Wasseiges", + "Waterloo", + "Wavre", + "Welkenraedt", + "Wellin", + "Yvoir",}; +} diff --git a/src/modules/location/data/belgium/BelgiumStates.h b/src/modules/location/data/belgium/BelgiumStates.h new file mode 100644 index 000000000..7b8bc4d09 --- /dev/null +++ b/src/modules/location/data/belgium/BelgiumStates.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector belgiumStates = { + "Anvers", + "Limbourg", + "Flandre occidentale", + "Flandre orientale", + "Hainaut", + "Liège", + "Luxembourg", + "Namur", + "Brabant flamand", + "Brabant wallon", + }; +} diff --git a/src/modules/location/data/belgium/BelgiumStreetPrefixes.h b/src/modules/location/data/belgium/BelgiumStreetPrefixes.h new file mode 100644 index 000000000..7deea679d --- /dev/null +++ b/src/modules/location/data/belgium/BelgiumStreetPrefixes.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector belgiumStreetPrefixes{"Allée", + "Chemin", + "Cours", + "Rue", + "Avenue", + "Boulevard", + "Drève", + "Galerie", + "Impasse", + "Jardin", + "Quai", + "Passage", + "Parc", + "Parvis", + "Place", + "Porte", + "Square", + "Voie",}; +} diff --git a/src/modules/location/data/belgium/BelgiumStreetSuffixes.h b/src/modules/location/data/belgium/BelgiumStreetSuffixes.h new file mode 100644 index 000000000..e5ab9db5d --- /dev/null +++ b/src/modules/location/data/belgium/BelgiumStreetSuffixes.h @@ -0,0 +1,219 @@ +#pragma once + +#include +#include + +namespace faker +{ +const std::vector belgiumStreetSuffixes{ + "de la Banque", + "de la Barbe", + "de Barchon", + "Baron Horta", + "aux Barques", + "des Barricades", + "Barthélémy", + "du Baudet", + "Frédéric Basse", + "du Béguinage", + "de Berlaimont", + "au Beurre", + "Henri Beyaert", + "de Bischoffsheim", + "Blaes", + "de la Blanchisserie", + "des Blindés", + "de la Bobine", + "Bodeghem", + "Bodenbroeck", + "des Boeufs", + "des Bogards", + "du Bois à Brûler", + "au Bois de Construction", + "du Bois Sauvage", + "des Boîteux", + "de Bon Secours", + "du Borgendael", + "Borgval", + "Bortier", + "des Bouchers", + "rue des Bouchers", + "du Boulet", + "de la Bouquetière", + "de la Bourse", + "de la Braie", + "des Brasseurs", + "Brederode", + "Jacques Brel", + "Breughel", + "des Brigittines", + "rue des Brigittines", + "aux Briques", + "des Brodeurs", + "de la Buanderie", + "Charles Buls", + "des Cadeaux", + "Camusel", + "du Canal", + "du Canon", + "Cantersteen", + "des Capucins", + "Cardinal Mercier", + "de la Caserne", + "des Cendres", + "du Centre", + "Chair et Pain", + "des Chaisiers", + "de la Chancellerie", + "des Chandeliers", + "du Chantier", + "du Chapelet", + "des Chapeliers", + "de la Chapelle", + "du Char", + "des Charpentiers", + "des Chartreux", + "du Chasseur", + "de la Chaufferette", + "à la Chaux", + "du Chêne", + "du Cheval", + "du Chevreuil", + "du Chien Marin", + "aux Choux", + "Christine", + "de la Cigogne", + "du Cirque", + "de la Clé", + "de la Collégiale", + "de la Colline", + "du Colombier", + "des Colonies", + "des Comédiens", + "des Commerçants", + "du Commerce", + "du Congrès", + "Coppens", + "Coudenberg", + "Jo Cox", + "de la Croix de Fer", + "Cuerens", + "des Cultes", + "de Cureghem", + "de la Cuve", + "du Cyprès", + "des Echelles", + "de l\' Eclipse", + "de l\' Economie", + "de l\' Ecuyer", + "d\' Egmont", + "de l\' Empereur", + "de l\' Enseignement", + "de l\' Epargne", + "de l\' Epée", + "des Eperonniers", + "de l\' Escalier", + "des Escrimeurs", + "d\' Espagne", + "de l\' Etuve", + "de l\' Europe", + "de l\' Eventail", + "de l\' Evêque", + "Evers", + "des Fabriques", + "des Faisans", + "de la Faucille", + "du Faucon", + "de la Ferraille", + "de la Fiancée", + "de la Fidélité", + "du Finistère", + "de Flandre", + "des Fleuristes", + "aux Fleurs", + "au Foin", + "Fontainas", + "de la Fontaine", + "de la Forêt d\'Houthulst", + "Fossé-aux-Loups", + "des Foulons", + "de la Fourche", + "des Fripiers", + "Froebel", + "blanche", + "noire", + "verte", + "pont de bois", + "grand poire", + "du marché", + "du lundi", + "des médias", + "Robert Schuman", + "du papier plié", + "de la croix de fer", + "cronque", + "de l\'Abbaye", + "Adolphe Mille", + "d\'Assas", + "du Bac", + "de Paris", + "La Boétie", + "du roi", + "de la Bûcherie", + "de Caumartin", + "Charlemagne", + "du Chat-qui-Pêche", + "de la Chaussée-d\'Antin", + "du Dahomey", + "Dauphine", + "Delesseux", + "du Faubourg Saint-Honoré", + "du Faubourg-Saint-Denis", + "de la Ferronnerie", + "des Francs-Bourgeois", + "des Grands Augustins", + "de la Harpe", + "du Havre", + "de la Huchette", + "Joubert", + "Laffitte", + "Lepic", + "des Lombards", + "Marcadet", + "Molière", + "Monsieur-le-Prince", + "de Montmorency", + "Montorgueil", + "Mouffetard", + "de Nesle", + "Oberkampf", + "de l\'Odéon", + "d\'Orsel", + "de la Paix", + "des Panoramas", + "Pastourelle", + "Pierre Charron", + "de la Pompe", + "de Presbourg", + "de Provence", + "de Richelieu", + "de Rivoli", + "des Rosiers", + "Royale", + "d\'Abbeville", + "Saint-Honoré", + "Saint-Bernard", + "Saint-Denis", + "Saint-Dominique", + "Saint-Jacques", + "Saint-Séverin", + "des Saussaies", + "de Seine", + "de Solférino", + "Du Sommerard", + "de Tilsitt", + "Vaneau", + "de Vaugirard", + "de la Victoire", + "Zadkine",}; +}