Does not yet test the backends properly, only validate them against each other (and gettext-rs) on the current machine.
JZXXFWQKOYAFQLQZDRALXG4KGEDR7JKO3AZ5Q5X7IQTS7BCJP3QAC
WBI5HFOBBUMDSGKY2RX3YA6N7YDCJEP23JNEJ7PG5VZXHLYIRJRQC
VNSHGQYNPGKGGPYNVP4Z2RWD7JCSDJVYAADD6UXWBYL6ZRXKLE4AC
UKFEFT6LSI4K7X6UHQFZYD52DILKXMZMYSO2UYS2FCHNPXIF4BEQC
O77KA6C4UJGZXVGPEA7WCRQH6XYQJPWETSPDXI3VOKOSRQND7JEQC
SHNZZSZGIBTTD4IV5SMW5BIN5DORUWQVTVTNB5RMRD5CTFNOMJ6AC
HCGVXOF7P3KKS2IMGVJWI2POVOZQFPXH26YVBJZRSOYSUM4CHUBQC
YNEOCYMGMSHQGCL5TOIGWDDKHE4BZ5M7FGY5I6B2V6JO6ZRCLETAC
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "cc"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d"
]
[[package]]
name = "gettext-rs"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e49ea8a8fad198aaa1f9655a2524b64b70eb06b2f3ff37da407566c93054f364"
dependencies = [
"gettext-sys",
"locale_config",
]
[[package]]
name = "gettext-sys"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c63ce2e00f56a206778276704bbe38564c8695249fdc8f354b4ef71c57c3839d"
dependencies = [
"cc",
"temp-dir",
]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]]
name = "objc_id"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
dependencies = [
"objc",
const GETTEXT_CATEGORIES: [GettextCategory; 13] = [
GettextCategory::LcAll,
GettextCategory::LcCType,
GettextCategory::LcCollate,
GettextCategory::LcMessages,
GettextCategory::LcMonetary,
GettextCategory::LcNumeric,
GettextCategory::LcTime,
GettextCategory::LcAddress,
GettextCategory::LcIdentification,
GettextCategory::LcMeasurement,
GettextCategory::LcName,
GettextCategory::LcPaper,
GettextCategory::LcTelephone,
];
#[test]
/// Exactly compare the output of get_locales_libc() with get_locales_custom()
fn compare_libc_with_custom_impl_exact() {
for gettext_category in GETTEXT_CATEGORIES {
let locale_select_category =
LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
let libc_locales = locale_select_category.get_locales_libc();
let custom_locales = locale_select_category.get_locales_custom();
assert_eq!(libc_locales, custom_locales);
}
}
#[test]
/// Compare the output of get_locales_libc() with get_locales_custom() using a HashSet
///
/// This will make sure that both functions return the same data, even if it's not
/// in the same order or items are duplicated. If the `_exact()` variant of this test
/// fails, this test may still pass.
fn compare_libc_with_custom_impl_hash_set() {
for gettext_category in GETTEXT_CATEGORIES {
let locale_select_category =
LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
let libc_locales: HashSet<String> =
HashSet::from_iter(locale_select_category.get_locales_libc().into_iter());
let custom_locales: HashSet<String> =
HashSet::from_iter(locale_select_category.get_locales_custom().into_iter());
assert_eq!(
libc_locales
.symmetric_difference(&custom_locales)
.collect::<Vec<_>>(),
Vec::<&String>::new()
);
}
}
#[test]
/// Compare get_locales_libc() with the implementation from gettext-rs
fn compare_libc_with_gettext() {
for gettext_category in GETTEXT_CATEGORIES {
let locale_select_category =
LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
let libc_locales = locale_select_category.get_locales_libc();
let gettext_locales =
String::from_utf8(gettextrs::setlocale(gettext_category, b"").unwrap()).unwrap();
assert_eq!(libc_locales[0], gettext_locales);
}
}
#[test]
/// Compare get_locales_custom() with the implementation from gettext-rs
fn compare_custom_with_gettext() {
for gettext_category in GETTEXT_CATEGORIES {
let locale_select_category =
LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
let custom_locales = locale_select_category.get_locales_custom();
let gettext_locales =
String::from_utf8(gettextrs::setlocale(gettext_category, b"").unwrap()).unwrap();
assert_eq!(custom_locales[0], gettext_locales);
}
}
[dev-dependencies]
gettext-rs = "0.7.0"