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

feat: added Palestine location data #977

Merged
merged 10 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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>(
charan-003 marked this conversation as resolved.
Show resolved Hide resolved

{
"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 PalestineStreetSuffix = std::to_array<std::string_view>({
"Shari' or Shari'a",
"Tariq",
"Jada",
"Midan",
"Zuqaq",
"Hara",
"Darb",
"Saha",
"Jisr"
}
);

const std::string_view PalestineZipCodeFormat{"P######"};
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; }));
}



Loading