Skip to content

Commit

Permalink
feat: added Palestine location data (#977)
Browse files Browse the repository at this point in the history
* Update location_data.h

Added data for Palestine

* Update location.cpp

Added case for Palestine

* Update location_test.cpp

added test cases for Palestine

* Update location_test.cpp

* Update location_test.cpp

* Update location.cpp

changed to camelCasing

* Update location_data.h

fixed camelCasing issues

* Update location_test.cpp

fixed the camelCasing issue

* Update location_test.cpp

changed all the camelCasing for palestine

* Update location_data.h

changed zipcode format from P####### to ########
  • Loading branch information
charan-003 authored Nov 15, 2024
1 parent 4c8a48d commit 58d922c
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 0 deletions.
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::ar_PS:
return palestineAddresses;
case Locale::es_MX:
return mexicoAddresses;
default:
Expand Down
179 changes: 179 additions & 0 deletions src/modules/location_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8234,6 +8234,185 @@ const CountryAddressesInfo mexicoAddresses{
{},
(mexicoStates),
};
// palestine
const auto palestineCities = std::to_array<std::string_view>(

{
"Gaza City",
"Hebron",
"Nablus",
"Jenin",
"Ramallah",
"Bethlehem",
"Jericho",
"Tulkarm",
"Qalqilya",
"Rafah",
"Khan Yunis",
"Beit Jala",
"Beit Sahour",
"Al-Bireh",
"Salfit",
"Tubas",
"Dura",
"Yatta",
"Halhul",
"Beitunia",
"Qabatiya",
"Anabta",
"Bani Na'im",
"Bani Suheila",
"Beit Hanoun",
"Beit Lahia",
"Deir al-Balah",
"Abasan al-Kabira",
"Abu Dis",
"Ad-Dhahiriya",
"Arraba",
"As-Samu",
"Azzun",
"Bala",
"Bani Zeid",
"Bidya",
"Birzeit",
"Bruqin",
"Deir Istiya",
"Hajja",
"Hizma",
"Idhna",
"Jaba",
"Jifna",
"Kafr Aqab",
"Kafr ad-Dik",
"Kafr al-Labad",
"Kafr Qaddum",
"Kharas",
"Qatanna"
});
const auto palestineStates = std::to_array<std::string_view>({
"Hebron",
"Bethlehem",
"Jerusalem",
"Ramallah and Al-Bireh",
"Salfit",
"Nablus",
"Qalqilya",
"Tulkarm",
"Jenin",
"Tubas",
"Jericho and the Jordan Valley",
"North Gaza",
"Gaza",
"Deir al-Balah",
"Khan Yunis",
"Rafah"
}
);
const auto palestineStreetNames = std::to_array<std::string_view>({
"Omar Mukhtar",
"Al-Shuhada",
"Star",
"Jamal Abdel Nasser",
"Al-Wehda",
"Al-Nuzha",
"Al-Irsal",
"Al-Manara",
"Al-Ma'arif",
"Al-Madares",
"Al-Quds",
"Al-Muntazah",
"Al-Ma'arad",
"Al-Baladiya",
"Al-Sa'a",
"Al-Masjid",
"Al-Mahkamah",
"Al-Maktaba",
"Al-Mahatta",
"Al-Masri",
"Al-Mujamma'",
"Al-Muhafaza",
"Al-Mu'assasa",
"Al-Mu'allimin",
"Al-Mu'askar",
"Al-Mu'awiya",
"Al-Mu'athafin",
"Al-Mu'askar Al-Jadid",
"Al-Mu'askar Al-Qadim",
"Al-Mu'askar Al-Shamali",
"Al-Mu'askar Al-Janubi",
"Al-Mu'askar Al-Gharbi",
"Al-Mu'askar Al-Sharqi",
"Al-Mu'askar Al-Awsat",
"Al-Mu'askar Al-Kabir",
"Al-Mu'askar Al-Saghir",
"Al-Mu'askar Al-Madina",
"Al-Mu'askar Al-Bahr",
"Al-Mu'askar Al-Jabal",
"Al-Mu'askar Al-Wadi",
"Al-Mu'askar Al-Sahil",
"Al-Mu'askar Al-Turab",
"Al-Mu'askar Al-Hajar",
"Al-Mu'askar Al-Nahr",
"Al-Mu'askar Al-Suq",
"Al-Mu'askar Al-Masna'",
"Al-Mu'askar Al-Madina Al-Qadima",
"Al-Mu'askar Al-Madina Al-Jadida",
"Al-Mu'askar Al-Madina Al-Munawara",
"Al-Mu'askar Al-Madina Al-Muqaddasa"
}
);

const auto palestineStreetSuffixes = std::to_array<std::string_view>({
"Shari' or Shari'a",
"Tariq",
"Jada",
"Midan",
"Zuqaq",
"Hara",
"Darb",
"Saha",
"Jisr"
}
);

const std::string_view palestineZipCodeFormat{"#######"};
const auto palestineAddressFormats =
std::to_array<std::string_view>({
"{street} {buildingNumber} {secondaryAddress}",
"{street} {buildingNumber}",
});
const auto palestineSecondaryAddressFormats = std::to_array<std::string_view>({
"Floor #",
"Apt. #",
});
const auto palestineBuildingNumberFormats = std::to_array<std::string_view>({
"#",
"##",
"###",
});
const auto palestineStreetFormats =
std::to_array<std::string_view>({
"{streetSuffix} {streetName}",
});
const auto palestineCityFormats = std::to_array<std::string_view>({
"{cityName}",
});

const CountryAddressesInfo palestineAddresses{
palestineZipCodeFormat,
palestineAddressFormats,
palestineSecondaryAddressFormats,
palestineStreetFormats,
{},
{palestineStreetNames},
palestineStreetSuffixes,
palestineBuildingNumberFormats,
palestineCityFormats,
{},
palestineCities,
{},
palestineStates,
};

// Poland

Expand Down
19 changes: 19 additions & 0 deletions tests/modules/location_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ CountryAddressesInfo getAddresses(const Locale& locale)
return israelAddresses;
case Locale::es_MX:
return mexicoAddresses;
case Locale::ar_PS:
return palestineAddresses;
default:
return usaAddresses;
}
Expand Down Expand Up @@ -1121,3 +1123,20 @@ TEST_F(LocationTest, shouldGenerateMexicoStreetAddress)
ASSERT_TRUE(std::ranges::any_of(mexicoStreetNames, [&generatedStreetAddress](const std::string_view& streetName)
{ return generatedStreetAddress.find(streetName) != std::string::npos; }));
}

TEST_F(LocationTest, shouldGeneratepalestineStreet)
{
const auto generatedStreet = street(Locale::ar_PS);
ASSERT_TRUE(std::ranges::any_of(palestineStreetNames, [&generatedStreet](const std::string_view& street)
{ return generatedStreet.find(street) != std::string::npos; }));
}

TEST_F(LocationTest, shouldGeneratepalestineStreetAddress)
{
const auto generatedStreetAddress = streetAddress(Locale::ar_PS);
ASSERT_TRUE(std::ranges::any_of(palestineStreetNames, [&generatedStreetAddress](const std::string_view& streetName)
{ return generatedStreetAddress.find(streetName) != std::string::npos; }));
}



0 comments on commit 58d922c

Please sign in to comment.