Skip to content

Commit

Permalink
feat: added mexico location data (#974)
Browse files Browse the repository at this point in the history
* added mexico location data

* cleaned up test and fix bug

---------

Co-authored-by: Juan Martinez <[email protected]>
  • Loading branch information
juanm18 and Juan Martinez authored Nov 11, 2024
1 parent cc16fa5 commit 4c8a48d
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/modules/location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ CountryAddressesInfo getAddresses(const Locale& locale)
return portugalAddresses;
case Locale::he_IL:
return israelAddresses;
case Locale::es_MX:
return mexicoAddresses;
default:
return usaAddresses;
}
Expand Down
175 changes: 175 additions & 0 deletions src/modules/location_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8060,6 +8060,181 @@ const CountryAddressesInfo italyAddresses{
(italyStates),
};

// Mexico

const auto mexicoCities = std::to_array<std::string_view>({
"Acapulco",
"Aguascalientes",
"Apizaco",
"Celaya",
"Chihuahua",
"Chilpancingo",
"Ciudad Juarez",
"Ciudad de Mexico",
"Colima",
"Cuernavaca",
"Culiacán",
"Delicias",
"Durango",
"Guadalajara",
"Guadalupe",
"Gomez Palacio",
"Hermosillo",
"Iguala",
"Irapuato",
"La Paz",
"León ato",
"Los Mochis",
"Mazatlán",
"Mérida",
"Mexicali",
"Minatitlán",
"Monterrey",
"Morelia",
"Nogales",
"Pachuca",
"Puebla",
"Puerto Vallarta",
"Querétaro",
"Reynosa",
"Rosarito",
"Saltillo",
"San Luis Potosí",
"San Nicolás de los Garza",
"San Pedro Garza García",
"Tapachula",
"Tepic",
"Tijuana",
"Toluca",
"Torreón",
"Tuxla Gutiérrez",
"Veracruz",
"Xalapa",
"Zacatecas",
"Zihuatanejo",
});

const auto mexicoStates = std::to_array<std::string_view>({
"Aguascalientes",
"Baja California",
"Baja California Sur",
"Campeche",
"Chiapas",
"Chihuahua",
"Coahuila",
"Colima",
"Durango",
"Guanajuato",
"Guerrero",
"Hidalgo",
"Jalisco",
"Ciudad de México (CDMX)",
"Michoacán",
"Morelos",
"Nayarit",
"Nuevo León",
"Oaxaca",
"Puebla",
"Querétaro",
"Quintana Roo",
"San Luis Potosí",
"Sinaloa",
"Sonora",
"Tabasco",
"Tamaulipas",
"Tlaxcala",
"Veracruz",
"Yucatán",
"Zacatecas",
});

const auto mexicoStreetNames = std::to_array<std::string_view>({
"Avenida Reforma",
"Avenida Insurgentes",
"Calle 5 de Febrero",
"Avenida Juárez",
"Calle Morelos",
"Calle Madero",
"Avenida de los Insurgentes",
"Avenida Zaragoza",
"Calle Hidalgo",
"Calle Prolongación Madero",
"Avenida Lázaro Cárdenas",
"Calle Benito Juárez",
"Calle Francisco I. Madero",
"Calle Pino Suárez",
"Avenida Tulum",
"Avenida México",
"Calle 16 de Septiembre",
"Calle Juárez",
"Avenida 20 de Noviembre",
"Calle Reforma",
"Avenida Veracruz",
"Calle Guerrero",
"Calle Oaxaca",
"Avenida 5 de Febrero",
"Avenida Constitución",
"Calle Lázaro Cárdenas",
"Calle Libertad",
"Calle Emiliano Zapata",
"Avenida Pino Suárez",
"Calle Ramon Ramirez",
"Avenida Independencia",
});

const auto mexicoStreetPrefixes =
std::to_array<std::string_view>({
"Calle",
"Avenida",
"Colonia",
"Paseo",
"Plaza",
});

const std::string_view mexicoZipCodeFormat{"#####"};

const auto mexicoAddressFormats =
std::to_array<std::string_view>({
"{street} {buildingNumber} {secondaryAddress}",
"{street} {buildingNumber})",
});

const auto mexicoSecondaryAddressFormats = std::to_array<std::string_view>({
"Piso. #",
"Apto. #",
});

const auto mexicoBuildingNumberFormats = std::to_array<std::string_view>({
"#",
"##",
"###",
});

const auto mexicoStreetFormats =
std::to_array<std::string_view>({
"{streetSuffix} {streetName}",
});

const auto mexicoCityFormats = std::to_array<std::string_view>({
"{cityName}",
});

const CountryAddressesInfo mexicoAddresses{
mexicoZipCodeFormat,
(mexicoAddressFormats),
(mexicoSecondaryAddressFormats),
(mexicoStreetFormats),
{},
{mexicoStreetNames},
(mexicoStreetPrefixes),
(mexicoBuildingNumberFormats),
(mexicoCityFormats),
{},
(mexicoCities),
{},
(mexicoStates),
};

// Poland

const auto polandCities = std::to_array<std::string_view>({
Expand Down
20 changes: 19 additions & 1 deletion tests/modules/location_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ CountryAddressesInfo getAddresses(const Locale& locale)
return portugalAddresses;
case Locale::he_IL:
return israelAddresses;
case Locale::es_MX:
return mexicoAddresses;
default:
return usaAddresses;
}
Expand Down Expand Up @@ -1102,4 +1104,20 @@ TEST_F(LocationTest, shouldGenerateIsraelStreetAddress)
{ return streetPrefix == generatedStreetPrefix; }));
ASSERT_TRUE(std::ranges::any_of(israelStreetNames, [&generatedStreetName](const std::string_view& streetName)
{ return streetName == generatedStreetName; }));
}
}

TEST_F(LocationTest, shouldGenerateMexicoStreet)
{
const auto generatedStreet = street(Locale::es_MX);

ASSERT_TRUE(std::ranges::any_of(mexicoStreetNames, [&generatedStreet](const std::string_view& street)
{ return generatedStreet.find(street) != std::string::npos; }));
}

TEST_F(LocationTest, shouldGenerateMexicoStreetAddress)
{
const auto generatedStreetAddress = streetAddress(Locale::es_MX);

ASSERT_TRUE(std::ranges::any_of(mexicoStreetNames, [&generatedStreetAddress](const std::string_view& streetName)
{ return generatedStreetAddress.find(streetName) != std::string::npos; }));
}

0 comments on commit 4c8a48d

Please sign in to comment.