summaryrefslogtreecommitdiffstats
path: root/vendor/icu_locid_transform/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/icu_locid_transform/tests
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/icu_locid_transform/tests')
-rw-r--r--vendor/icu_locid_transform/tests/fixtures/canonicalize.json444
-rw-r--r--vendor/icu_locid_transform/tests/fixtures/maximize.json182
-rw-r--r--vendor/icu_locid_transform/tests/fixtures/minimize.json26
-rw-r--r--vendor/icu_locid_transform/tests/fixtures/mod.rs12
-rw-r--r--vendor/icu_locid_transform/tests/helpers/mod.rs15
-rw-r--r--vendor/icu_locid_transform/tests/locale_canonicalizer.rs82
6 files changed, 761 insertions, 0 deletions
diff --git a/vendor/icu_locid_transform/tests/fixtures/canonicalize.json b/vendor/icu_locid_transform/tests/fixtures/canonicalize.json
new file mode 100644
index 000000000..89e6cec05
--- /dev/null
+++ b/vendor/icu_locid_transform/tests/fixtures/canonicalize.json
@@ -0,0 +1,444 @@
+[
+ {
+ "input": "es",
+ "output": "es"
+ },
+ {
+ "input": "en-CA",
+ "output": "en-CA"
+ },
+ {
+ "input": "cka",
+ "output": "cmr"
+ },
+ {
+ "input": "cze",
+ "output": "cs"
+ },
+ {
+ "input": "gfx",
+ "output": "vaj"
+ },
+ {
+ "input": "sgn-BR",
+ "output": "bzs"
+ },
+ {
+ "input": "sgn-DD",
+ "output": "gsg"
+ },
+ {
+ "input": "tam",
+ "output": "ta"
+ },
+ {
+ "input": "und-aaland",
+ "output": "und-AX"
+ },
+ {
+ "input": "nob-bokmal",
+ "output": "nb"
+ },
+ {
+ "input": "no-nynorsk",
+ "output": "nn"
+ },
+ {
+ "input": "und-Qaai",
+ "output": "und-Zinh"
+ },
+ {
+ "input": "en-554",
+ "output": "en-NZ"
+ },
+ {
+ "input": "en-084",
+ "output": "en-BZ"
+ },
+ {
+ "input": "art-lojban",
+ "output": "jbo"
+ },
+ {
+ "input": "zh-guoyu",
+ "output": "zh"
+ },
+ {
+ "input": "zh-hakka",
+ "output": "hak"
+ },
+ {
+ "input": "zh-xiang",
+ "output": "hsn"
+ },
+ {
+ "input": "aar-x-private",
+ "output": "aa-x-private"
+ },
+ {
+ "input": "heb-x-private",
+ "output": "he-x-private"
+ },
+ {
+ "input": "ces",
+ "output": "cs"
+ },
+ {
+ "input": "hy-arevela",
+ "output": "hy"
+ },
+ {
+ "input": "hy-arevmda",
+ "output": "hyw"
+ },
+ {
+ "input": "cel-gaulish",
+ "output": "xtg"
+ },
+ {
+ "input": "ja-latn-hepburn-heploc",
+ "output": "ja-Latn-alalc97"
+ },
+ {
+ "input": "ja-Latn-fonipa-hepburn-heploc",
+ "output": "ja-Latn-alalc97-fonipa"
+ },
+ {
+ "input": "und-Armn-SU",
+ "output": "und-Armn-AM"
+ },
+ {
+ "input": "sh",
+ "output": "sr-Latn"
+ },
+ {
+ "input": "sh-Cyrl",
+ "output": "sr-Cyrl"
+ },
+ {
+ "input": "cnr",
+ "output": "sr-ME"
+ },
+ {
+ "input": "cnr-BA",
+ "output": "sr-BA"
+ },
+ {
+ "input": "ru-SU",
+ "output": "ru-RU"
+ },
+ {
+ "input": "ru-810",
+ "output": "ru-RU"
+ },
+ {
+ "input": "en-SU",
+ "output": "en-RU"
+ },
+ {
+ "input": "en-810",
+ "output": "en-RU"
+ },
+ {
+ "input": "und-SU",
+ "output": "und-RU"
+ },
+ {
+ "input": "und-810",
+ "output": "und-RU"
+ },
+ {
+ "input": "und-Latn-SU",
+ "output": "und-Latn-RU"
+ },
+ {
+ "input": "und-Latn-810",
+ "output": "und-Latn-RU"
+ },
+ {
+ "input": "hy-SU",
+ "output": "hy-AM"
+ },
+ {
+ "input": "hy-810",
+ "output": "hy-AM"
+ },
+ {
+ "input": "und-Armn-SU",
+ "output": "und-Armn-AM"
+ },
+ {
+ "input": "und-Armn-810",
+ "output": "und-Armn-AM"
+ },
+ {
+ "input": "sr-CS",
+ "output": "sr-RS"
+ },
+ {
+ "input": "sr-Latn-CS",
+ "output": "sr-Latn-RS"
+ },
+ {
+ "input": "sr-Cyrl-CS",
+ "output": "sr-Cyrl-RS"
+ },
+ {
+ "input": "az-NT",
+ "output": "az-SA"
+ },
+ {
+ "input": "sl-t-sl-rozaj-biske-1994",
+ "output": "sl-t-sl-1994-biske-rozaj"
+ },
+ {
+ "input": "DE-T-M0-DIN-K0-QWERTZ",
+ "output": "de-t-k0-qwertz-m0-din"
+ },
+ {
+ "input": "en-t-m0-true",
+ "output": "en-t-m0-true"
+ },
+ {
+ "input": "en-t-iw",
+ "output": "en-t-he"
+ },
+ {
+ "input": "und-u-rg-no23",
+ "output": "und-u-rg-no50"
+ },
+ {
+ "input": "und-u-rg-cn11",
+ "output": "und-u-rg-cnbj"
+ },
+ {
+ "input": "und-u-rg-cz10a",
+ "output": "und-u-rg-cz110"
+ },
+ {
+ "input": "und-u-rg-fra",
+ "output": "und-u-rg-frges"
+ },
+ {
+ "input": "und-u-rg-frg",
+ "output": "und-u-rg-frges"
+ },
+ {
+ "input": "und-u-rg-lud",
+ "output": "und-u-rg-lucl"
+ },
+ {
+ "input": "und-NO-u-rg-no23",
+ "output": "und-NO-u-rg-no50"
+ },
+ {
+ "input": "und-CN-u-rg-cn11",
+ "output": "und-CN-u-rg-cnbj"
+ },
+ {
+ "input": "und-CZ-u-rg-cz10a",
+ "output": "und-CZ-u-rg-cz110"
+ },
+ {
+ "input": "und-FR-u-rg-fra",
+ "output": "und-FR-u-rg-frges"
+ },
+ {
+ "input": "und-FR-u-rg-frg",
+ "output": "und-FR-u-rg-frges"
+ },
+ {
+ "input": "und-u-rg-lud",
+ "output": "und-u-rg-lucl"
+ },
+ {
+ "input": "und-u-sd-no23",
+ "output": "und-u-sd-no50"
+ },
+ {
+ "input": "und-u-sd-cn11",
+ "output": "und-u-sd-cnbj"
+ },
+ {
+ "input": "und-u-sd-cz10a",
+ "output": "und-u-sd-cz110"
+ },
+ {
+ "input": "und-u-sd-fra",
+ "output": "und-u-sd-frges"
+ },
+ {
+ "input": "hy-arevela",
+ "output": "hy"
+ },
+ {
+ "input": "hy-Armn-arevela",
+ "output": "hy-Armn"
+ },
+ {
+ "input": "hy-AM-arevela",
+ "output": "hy-AM"
+ },
+ {
+ "input": "hy-arevela-fonipa",
+ "output": "hy-fonipa"
+ },
+ {
+ "input": "hy-fonipa-arevela",
+ "output": "hy-fonipa"
+ },
+ {
+ "input": "hy-arevmda",
+ "output": "hyw"
+ },
+ {
+ "input": "hy-Armn-arevmda",
+ "output": "hyw-Armn"
+ },
+ {
+ "input": "hy-AM-arevmda",
+ "output": "hyw-AM"
+ },
+ {
+ "input": "hy-arevmda-fonipa",
+ "output": "hyw-fonipa"
+ },
+ {
+ "input": "hy-fonipa-arevmda",
+ "output": "hyw-fonipa"
+ },
+ {
+ "input": "ja-Latn-hepburn-heploc",
+ "output": "ja-Latn-alalc97"
+ },
+ {
+ "input": "ja-Latn-JP-hepburn-heploc",
+ "output": "ja-Latn-JP-alalc97"
+ },
+ {
+ "input": "sv-aaland",
+ "output": "sv-AX"
+ },
+ {
+ "input": "el-polytoni",
+ "output": "el-polyton"
+ },
+ {
+ "input": "ja-Latn-alalc97-hepburn-heploc",
+ "output": "ja-Latn-alalc97"
+ },
+ {
+ "input": "ja-Latn-hepburn-alalc97-heploc",
+ "output": "ja-Latn-alalc97"
+ },
+ {
+ "input": "ja-Latn-hepburn-heploc-alalc97",
+ "output": "ja-Latn-alalc97"
+ },
+ {
+ "input": "ja-Latn-heploc-hepburn",
+ "output": "ja-Latn-alalc97"
+ },
+ {
+ "input": "ja-Latn-heploc",
+ "output": "ja-Latn-alalc97"
+ },
+ {
+ "input": "ja-Latn-aaland-heploc",
+ "output": "ja-Latn-AX-alalc97"
+ },
+ {
+ "input": "ja-Latn-heploc-polytoni",
+ "output": "ja-Latn-alalc97-polyton"
+ },
+ {
+ "input": "und-Latn-t-und-hani-m0-names",
+ "output": "und-Latn-t-und-hani-m0-prprname",
+ "disabled": true
+ },
+ {
+ "input": "und-u-ca-ethiopian-amete-alem",
+ "output": "und-u-ca-ethioaa",
+ "disabled": true
+ },
+ {
+ "input": "und-u-ca-islamicc",
+ "output": "und-u-ca-islamic-civil",
+ "disabled": true
+ },
+ {
+ "input": "und-u-ks-primary",
+ "output": "und-u-ks-level1",
+ "disabled": true
+ },
+ {
+ "input": "und-u-ks-tertiary",
+ "output": "und-u-ks-level3",
+ "disabled": true
+ },
+ {
+ "input": "und-u-ms-imperial",
+ "output": "und-u-ms-uksystem",
+ "disabled": true
+ },
+ {
+ "input": "und-u-kb-yes",
+ "output": "und-u-kb",
+ "disabled": true
+ },
+ {
+ "input": "und-u-kc-yes",
+ "output": "und-u-k",
+ "disabled": true
+ },
+ {
+ "input": "und-u-kh-yes",
+ "output": "und-u-kh",
+ "disabled": true
+ },
+ {
+ "input": "und-u-kk-yes",
+ "output": "und-u-kk",
+ "disabled": true
+ },
+ {
+ "input": "und-u-kn-yes",
+ "output": "und-u-kn",
+ "disabled": true
+ },
+ {
+ "input": "und-u-ka-yes",
+ "output": "und-u-ka-yes",
+ "disabled": true
+ },
+ {
+ "input": "und-u-tz-cnckg",
+ "output": "und-u-tz-cnsha",
+ "disabled": true
+ },
+ {
+ "input": "und-u-tz-eire",
+ "output": "und-u-tz-iedub",
+ "disabled": true
+ },
+ {
+ "input": "und-u-tz-est",
+ "output": "und-u-tz-utcw05",
+ "disabled": true
+ },
+ {
+ "input": "und-u-tz-gmt0",
+ "output": "und-u-tz-gmt",
+ "disabled": true
+ },
+ {
+ "input": "und-u-tz-uct",
+ "output": "und-u-tz-utc",
+ "disabled": true
+ },
+ {
+ "input": "und-u-tz-zulu",
+ "output": "und-u-tz-utc",
+ "disabled": true
+ }
+] \ No newline at end of file
diff --git a/vendor/icu_locid_transform/tests/fixtures/maximize.json b/vendor/icu_locid_transform/tests/fixtures/maximize.json
new file mode 100644
index 000000000..86b9b2fe8
--- /dev/null
+++ b/vendor/icu_locid_transform/tests/fixtures/maximize.json
@@ -0,0 +1,182 @@
+[
+ {
+ "input": "en-US",
+ "output": "en-Latn-US"
+ },
+ {
+ "input": "en-GB",
+ "output": "en-Latn-GB"
+ },
+ {
+ "input": "es-AR",
+ "output": "es-Latn-AR"
+ },
+ {
+ "input": "it",
+ "output": "it-Latn-IT"
+ },
+ {
+ "input": "zh-Hans-CN",
+ "output": "zh-Hans-CN"
+ },
+ {
+ "input": "de-AT",
+ "output": "de-Latn-AT"
+ },
+ {
+ "input": "pl",
+ "output": "pl-Latn-PL"
+ },
+ {
+ "input": "fr-FR",
+ "output": "fr-Latn-FR"
+ },
+ {
+ "input": "de-AT",
+ "output": "de-Latn-AT"
+ },
+ {
+ "input": "sr-Cyrl-SR",
+ "output": "sr-Cyrl-SR"
+ },
+ {
+ "input": "nb-NO",
+ "output": "nb-Latn-NO"
+ },
+ {
+ "input": "fr-FR",
+ "output": "fr-Latn-FR"
+ },
+ {
+ "input": "mk",
+ "output": "mk-Cyrl-MK"
+ },
+ {
+ "input": "uk",
+ "output": "uk-Cyrl-UA"
+ },
+ {
+ "input": "und-PL",
+ "output": "pl-Latn-PL"
+ },
+ {
+ "input": "und-Latn-AM",
+ "output": "ku-Latn-AM"
+ },
+ {
+ "input": "ug-Cyrl",
+ "output": "ug-Cyrl-KZ"
+ },
+ {
+ "input": "sr-ME",
+ "output": "sr-Latn-ME"
+ },
+ {
+ "input": "mn-Mong",
+ "output": "mn-Mong-CN"
+ },
+ {
+ "input": "lif-Limb",
+ "output": "lif-Limb-IN"
+ },
+ {
+ "input": "gan",
+ "output": "gan-Hans-CN"
+ },
+ {
+ "input": "zh-Hant",
+ "output": "zh-Hant-TW"
+ },
+ {
+ "input": "yue-Hans",
+ "output": "yue-Hans-CN"
+ },
+ {
+ "input": "unr",
+ "output": "unr-Beng-IN"
+ },
+ {
+ "input": "unr-Deva",
+ "output": "unr-Deva-NP"
+ },
+ {
+ "input": "und-Thai-CN",
+ "output": "lcp-Thai-CN"
+ },
+ {
+ "input": "ug-Cyrl",
+ "output": "ug-Cyrl-KZ"
+ },
+ {
+ "input": "en-Latn-DE",
+ "output": "en-Latn-DE"
+ },
+ {
+ "input": "pl-FR",
+ "output": "pl-Latn-FR"
+ },
+ {
+ "input": "de-CH",
+ "output": "de-Latn-CH"
+ },
+ {
+ "input": "tuq",
+ "output": "tuq-Latn-ZZ"
+ },
+ {
+ "input": "sr-ME",
+ "output": "sr-Latn-ME"
+ },
+ {
+ "input": "ng",
+ "output": "ng-Latn-NA"
+ },
+ {
+ "input": "klx",
+ "output": "klx-Latn-ZZ"
+ },
+ {
+ "input": "kk-Arab",
+ "output": "kk-Arab-CN"
+ },
+ {
+ "input": "en-Cyrl",
+ "output": "en-Cyrl-US"
+ },
+ {
+ "input": "und-Cyrl-UK",
+ "output": "ru-Cyrl-UK"
+ },
+ {
+ "input": "und-Arab",
+ "output": "ar-Arab-EG"
+ },
+ {
+ "input": "und-Arab-FO",
+ "output": "ar-Arab-FO"
+ },
+ {
+ "input": "zh-TW",
+ "output": "zh-Hant-TW"
+ },
+ {
+ "input": "und",
+ "output": "en-Latn-US"
+ },
+ {
+ "input": "zh-SG",
+ "output": "zh-Hans-SG"
+ },
+ {
+ "input": "und-TW",
+ "output": "zh-Hant-TW"
+ },
+ {
+ "input": "zh-hant-u-nu-Chinese-hc-h24",
+ "output": "zh-Hant-TW-u-hc-h24-nu-chinese"
+ },
+ {
+ "input": "und-latn-AQ",
+ "output": "und-Latn-AQ"
+ }
+]
diff --git a/vendor/icu_locid_transform/tests/fixtures/minimize.json b/vendor/icu_locid_transform/tests/fixtures/minimize.json
new file mode 100644
index 000000000..6c225e230
--- /dev/null
+++ b/vendor/icu_locid_transform/tests/fixtures/minimize.json
@@ -0,0 +1,26 @@
+[
+ {
+ "input": "zh-Hant",
+ "output": "zh-TW"
+ },
+ {
+ "input": "en-Latn-US",
+ "output": "en"
+ },
+ {
+ "input": "en",
+ "output": "en"
+ },
+ {
+ "input": "und",
+ "output": "en"
+ },
+ {
+ "input": "es-ES-preeuro",
+ "output": "es-preeuro"
+ },
+ {
+ "input": "zh-Hant-TW-u-hc-h24-nu-chinese",
+ "output": "zh-TW-u-hc-h24-nu-chinese"
+ }
+]
diff --git a/vendor/icu_locid_transform/tests/fixtures/mod.rs b/vendor/icu_locid_transform/tests/fixtures/mod.rs
new file mode 100644
index 000000000..70dfb0381
--- /dev/null
+++ b/vendor/icu_locid_transform/tests/fixtures/mod.rs
@@ -0,0 +1,12 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use serde::Deserialize;
+
+#[derive(Deserialize)]
+pub struct CanonicalizationTest {
+ pub input: String,
+ pub output: String,
+ pub disabled: Option<bool>,
+}
diff --git a/vendor/icu_locid_transform/tests/helpers/mod.rs b/vendor/icu_locid_transform/tests/helpers/mod.rs
new file mode 100644
index 000000000..d250c510c
--- /dev/null
+++ b/vendor/icu_locid_transform/tests/helpers/mod.rs
@@ -0,0 +1,15 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use std::fs::File;
+use std::io::{BufReader, Error};
+
+pub fn read_fixture<T>(path: &str) -> Result<T, Error>
+where
+ T: serde::de::DeserializeOwned,
+{
+ let file = File::open(path)?;
+ let reader = BufReader::new(file);
+ Ok(serde_json::from_reader(reader)?)
+}
diff --git a/vendor/icu_locid_transform/tests/locale_canonicalizer.rs b/vendor/icu_locid_transform/tests/locale_canonicalizer.rs
new file mode 100644
index 000000000..06e360f53
--- /dev/null
+++ b/vendor/icu_locid_transform/tests/locale_canonicalizer.rs
@@ -0,0 +1,82 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+mod fixtures;
+mod helpers;
+
+use icu_locid::Locale;
+use icu_locid_transform::{LocaleCanonicalizer, LocaleExpander, TransformResult};
+use writeable::assert_writeable_eq;
+
+#[test]
+fn test_maximize() {
+ let lc = LocaleExpander::new_extended();
+
+ let path = "./tests/fixtures/maximize.json";
+ let testcases: Vec<fixtures::CanonicalizationTest> =
+ helpers::read_fixture(path).expect("Failed to read a fixture");
+
+ for case in testcases {
+ if let Some(true) = case.disabled {
+ continue;
+ }
+ let mut locale: Locale = case.input.parse().unwrap();
+ let unmodified = locale.clone();
+ let result = lc.maximize(&mut locale);
+ assert_writeable_eq!(locale, case.output);
+ if result == TransformResult::Modified {
+ assert_ne!(locale, unmodified);
+ } else {
+ assert_eq!(locale, unmodified);
+ }
+ }
+}
+
+#[test]
+fn test_minimize() {
+ let lc = LocaleExpander::new_extended();
+
+ let path = "./tests/fixtures/minimize.json";
+ let testcases: Vec<fixtures::CanonicalizationTest> =
+ helpers::read_fixture(path).expect("Failed to read a fixture");
+
+ for case in testcases {
+ if let Some(true) = case.disabled {
+ continue;
+ }
+ let mut locale: Locale = case.input.parse().unwrap();
+ let unmodified = locale.clone();
+ let result = lc.minimize(&mut locale);
+ assert_writeable_eq!(locale, case.output);
+ if result == TransformResult::Modified {
+ assert_ne!(locale, unmodified);
+ } else {
+ assert_eq!(locale, unmodified);
+ }
+ }
+}
+
+#[test]
+fn test_canonicalize() {
+ let lc = LocaleCanonicalizer::new();
+
+ let path = "./tests/fixtures/canonicalize.json";
+ let testcases: Vec<fixtures::CanonicalizationTest> =
+ helpers::read_fixture(path).expect("Failed to read a fixture");
+
+ for case in testcases {
+ if let Some(true) = case.disabled {
+ continue;
+ }
+ let mut locale: Locale = case.input.parse().expect("Unable to parse input");
+ let unmodified = locale.clone();
+ let result = lc.canonicalize(&mut locale);
+ assert_writeable_eq!(locale, case.output);
+ if result == TransformResult::Modified {
+ assert_ne!(locale, unmodified);
+ } else {
+ assert_eq!(locale, unmodified);
+ }
+ }
+}