i18n: the shipped-locale collation test checks each locale's own order

This commit is contained in:
aiongg
2026-10-23 08:15:24 +00:00
parent 6ea2d2c7f2
commit 72a1dc7728
+41 -39
View File
@@ -131,48 +131,50 @@ mod tests {
v v
} }
/// Each tailored locale puts a pair in another order than the root collation does, which a
/// locale whose data is missing (it falls back to root) wouldn't.
#[test] #[test]
fn every_shipped_locale_has_its_data() { fn every_shipped_locale_has_its_data() {
for locale in [ let root = Collator::new("und");
"en", for (locale, first, second) in [
"ar", ("ar", "ب", "a"),
"bg", ("bg", "б", "a"),
"cs", ("cs", "hrad", "chata"),
"da", ("da", "zebra", "år"),
"de", ("el", "β", "a"),
"el", ("es", "nube", "ñu"),
"es", ("et", "wc", "õun"),
"et", ("fa", "ب", "a"),
"fa", ("fi", "zeta", "äiti"),
"fi", ("hi", "क", "a"),
"fr", ("hr", "cvijet", "čaj"),
"hi", ("hu", "cukor", "csak"),
"hr", ("ja", "亜", "一"),
"hu", ("ka", "ა", "a"),
"id", ("kk", "б", "a"),
"it", ("ko", "가", "a"),
"ja", ("lt", "yra", "jau"),
"ka", ("pl", "az", "ąb"),
"kk", ("ru", "б", "a"),
"ko", ("sl", "cvet", "čaj"),
"lt", ("sr", "б", "a"),
"nl", ("sr-latn", "cvijet", "čaj"),
"pl", ("sv", "zebra", "år"),
"pt-br", ("te", "క", "a"),
"ru", ("tr", "cz", "ça"),
"sl", ("uk", "б", "a"),
"sr", ("vi", "az", "ăn"),
"sr-latn", ("zh-hans", "阿", "中"),
"sv", ("zh-hant", "人", "丈"),
"te",
"tr",
"uk",
"vi",
"zh-hans",
"zh-hant",
"not a locale",
] { ] {
assert!(Collator::new(locale).0.is_some(), "{locale}"); assert_eq!(Collator::new(locale).compare(first, second), Ordering::Less, "{locale}: {first} < {second}");
assert_eq!(root.compare(first, second), Ordering::Greater, "root: {second} < {first}");
}
// CLDR doesn't tailor these: they sort in the root order.
for locale in ["en", "de", "fr", "id", "it", "nl", "pt-br", "not a locale"] {
let collator = Collator::new(locale);
assert!(collator.0.is_some(), "{locale}");
assert_eq!(collator.compare("čaj", "cvijet"), Ordering::Less, "{locale}");
} }
} }