summaryrefslogtreecommitdiffstats
path: root/vendor/icu_locid/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
commit2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch)
treed325add32978dbdc1db975a438b3a77d571b1ab8 /vendor/icu_locid/tests
parentReleasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff)
downloadrustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz
rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/icu_locid/tests')
-rw-r--r--vendor/icu_locid/tests/fixtures/invalid-extensions.json40
-rw-r--r--vendor/icu_locid/tests/fixtures/invalid.json49
-rw-r--r--vendor/icu_locid/tests/fixtures/mod.rs1
-rw-r--r--vendor/icu_locid/tests/langid.rs15
-rw-r--r--vendor/icu_locid/tests/locale.rs16
5 files changed, 105 insertions, 16 deletions
diff --git a/vendor/icu_locid/tests/fixtures/invalid-extensions.json b/vendor/icu_locid/tests/fixtures/invalid-extensions.json
index a5f3a923d..3aff2636b 100644
--- a/vendor/icu_locid/tests/fixtures/invalid-extensions.json
+++ b/vendor/icu_locid/tests/fixtures/invalid-extensions.json
@@ -108,5 +108,45 @@
"error": "InvalidExtension",
"text": "Invalid subtag"
}
+ },
+ {
+ "input": {
+ "type": "Locale",
+ "identifier": "de-u-ca-"
+ },
+ "output": {
+ "error": "InvalidExtension",
+ "text": "Invalid subtag"
+ }
+ },
+ {
+ "input": {
+ "type": "Locale",
+ "identifier": "de-u-ca-gregory-"
+ },
+ "output": {
+ "error": "InvalidExtension",
+ "text": "Invalid subtag"
+ }
+ },
+ {
+ "input": {
+ "type": "Locale",
+ "identifier": "de-u-ca-gregory-u-hc-hc24"
+ },
+ "output": {
+ "error": "DuplicatedExtension",
+ "text": "Duplicated extension"
+ }
+ },
+ {
+ "input": {
+ "type": "Locale",
+ "identifier": "de-l-foo-l-bar"
+ },
+ "output": {
+ "error": "DuplicatedExtension",
+ "text": "Duplicated extension"
+ }
}
]
diff --git a/vendor/icu_locid/tests/fixtures/invalid.json b/vendor/icu_locid/tests/fixtures/invalid.json
index d44007596..c22459e65 100644
--- a/vendor/icu_locid/tests/fixtures/invalid.json
+++ b/vendor/icu_locid/tests/fixtures/invalid.json
@@ -1,5 +1,54 @@
[
{
+ "input": "-",
+ "output": {
+ "error": "InvalidLanguage",
+ "text": "The given language subtag is invalid"
+ }
+ },
+ {
+ "input": "--",
+ "output": {
+ "error": "InvalidLanguage",
+ "text": "The given subtag is invalid"
+ }
+ },
+ {
+ "input": "en-",
+ "output": {
+ "error": "InvalidSubtag",
+ "text": "The given subtag is invalid"
+ }
+ },
+ {
+ "input": "-en",
+ "output": {
+ "error": "InvalidLanguage",
+ "text": "The given subtag is invalid"
+ }
+ },
+ {
+ "input": "en-us-",
+ "output": {
+ "error": "InvalidSubtag",
+ "text": "The given subtag is invalid"
+ }
+ },
+ {
+ "input": "en--US",
+ "output": {
+ "error": "InvalidSubtag",
+ "text": "The given subtag is invalid"
+ }
+ },
+ {
+ "input": "-e-",
+ "output": {
+ "error": "InvalidLanguage",
+ "text": "The given subtag is invalid"
+ }
+ },
+ {
"input": "a1a",
"output": {
"error": "InvalidLanguage",
diff --git a/vendor/icu_locid/tests/fixtures/mod.rs b/vendor/icu_locid/tests/fixtures/mod.rs
index b688632ba..f00fd6c3b 100644
--- a/vendor/icu_locid/tests/fixtures/mod.rs
+++ b/vendor/icu_locid/tests/fixtures/mod.rs
@@ -248,6 +248,7 @@ impl From<LocaleError> for ParserError {
"InvalidLanguage" => ParserError::InvalidLanguage,
"InvalidSubtag" => ParserError::InvalidSubtag,
"InvalidExtension" => ParserError::InvalidExtension,
+ "DuplicatedExtension" => ParserError::DuplicatedExtension,
_ => unreachable!("Unknown error name"),
}
}
diff --git a/vendor/icu_locid/tests/langid.rs b/vendor/icu_locid/tests/langid.rs
index 96d022a9b..60414e087 100644
--- a/vendor/icu_locid/tests/langid.rs
+++ b/vendor/icu_locid/tests/langid.rs
@@ -6,6 +6,7 @@ mod fixtures;
mod helpers;
use std::convert::TryInto;
+use writeable::*;
use icu_locid::{subtags, LanguageIdentifier, ParserError};
@@ -21,7 +22,7 @@ fn test_langid_fixtures(tests: Vec<fixtures::LocaleTest>) {
}
}
let input: LanguageIdentifier = test.input.try_into().expect("Parsing failed.");
- assert_eq!(input.to_string(), s);
+ assert_writeable_eq!(input, s);
}
fixtures::LocaleInfo::Error(err) => {
let err: ParserError = err.into();
@@ -83,28 +84,28 @@ fn test_langid_subtag_language() {
assert_eq!(lang, subtags::Language::UND);
assert!(lang.is_empty());
- assert_eq!(lang.to_string(), "und");
+ assert_writeable_eq!(lang, "und");
}
#[test]
fn test_langid_subtag_region() {
let region: subtags::Region = "en".parse().expect("Failed to parse a region.");
assert_eq!(region.as_str(), "EN");
- assert_eq!(region.to_string(), "EN");
+ assert_writeable_eq!(region, "EN");
}
#[test]
fn test_langid_subtag_script() {
let script: subtags::Script = "Latn".parse().expect("Failed to parse a script.");
assert_eq!(script.as_str(), "Latn");
- assert_eq!(script.to_string(), "Latn");
+ assert_writeable_eq!(script, "Latn");
}
#[test]
fn test_langid_subtag_variant() {
let variant: subtags::Variant = "macos".parse().expect("Failed to parse a variant.");
assert_eq!(variant.as_str(), "macos");
- assert_eq!(variant.to_string(), "macos");
+ assert_writeable_eq!(variant, "macos");
}
#[test]
@@ -123,7 +124,7 @@ fn test_langid_normalizing_eq_str() {
helpers::read_fixture(path).expect("Failed to read a fixture");
for test in tests {
let parsed: LanguageIdentifier = test.input.try_into().expect("Parsing failed.");
- assert!(parsed.normalizing_eq(parsed.to_string().as_str()));
+ assert!(parsed.normalizing_eq(&*parsed.write_to_string()));
}
// Check that trailing characters are not ignored
@@ -148,7 +149,7 @@ fn test_langid_strict_cmp() {
let a_langid = a
.parse::<LanguageIdentifier>()
.expect("Invalid BCP-47 in fixture");
- let a_normalized = a_langid.to_string();
+ let a_normalized = a_langid.write_to_string();
let string_cmp = a_normalized.as_bytes().cmp(b.as_bytes());
let test_cmp = a_langid.strict_cmp(b.as_bytes());
assert_eq!(string_cmp, test_cmp, "{:?}/{:?}", a, b);
diff --git a/vendor/icu_locid/tests/locale.rs b/vendor/icu_locid/tests/locale.rs
index 37c43181e..cd3448983 100644
--- a/vendor/icu_locid/tests/locale.rs
+++ b/vendor/icu_locid/tests/locale.rs
@@ -6,6 +6,7 @@ mod fixtures;
mod helpers;
use std::convert::TryInto;
+use writeable::*;
use icu_locid::{LanguageIdentifier, Locale, ParserError};
@@ -16,7 +17,7 @@ fn test_langid_fixtures(tests: Vec<fixtures::LocaleTest>) {
match test.output {
fixtures::LocaleInfo::String(s) => {
let input: Locale = test.input.try_into().expect("Parsing failed.");
- assert_eq!(input.to_string(), s);
+ assert_writeable_eq!(input, s);
}
fixtures::LocaleInfo::Error(err) => {
let err: ParserError = err.into();
@@ -27,7 +28,7 @@ fn test_langid_fixtures(tests: Vec<fixtures::LocaleTest>) {
let input: Locale = test.input.try_into().expect("Parsing failed.");
let output: Locale = ident.clone().try_into().expect("Parsing failed.");
assert_eq!(input, output);
- assert_eq!(input.to_string(), ident.identifier);
+ assert_writeable_eq!(input, ident.identifier);
}
fixtures::LocaleInfo::Object(o) => {
let input: Locale = test.input.try_into().expect("Parsing failed.");
@@ -58,7 +59,7 @@ fn test_langid_invalid() {
fn test_locale_is_empty() {
let locale: Locale = Locale::default();
assert!(locale.extensions.is_empty());
- assert_eq!(locale.to_string(), "und".to_string());
+ assert_writeable_eq!(locale, "und");
}
#[test]
@@ -74,10 +75,7 @@ fn test_locale_canonicalize() {
let locale: Locale = "En-latn-US-MacOS"
.parse()
.expect("Failed to parse a locale.");
- assert_eq!(
- locale.to_string(),
- Locale::canonicalize("eN-latN-uS-macOS").unwrap()
- );
+ assert_writeable_eq!(locale, Locale::canonicalize("eN-latN-uS-macOS").unwrap());
}
#[test]
@@ -87,7 +85,7 @@ fn test_locale_normalizing_eq_str() {
helpers::read_fixture(path).expect("Failed to read a fixture");
for test in tests {
let parsed: Locale = test.input.try_into().expect("Parsing failed.");
- assert!(parsed.normalizing_eq(parsed.to_string().as_str()));
+ assert!(parsed.normalizing_eq(&*parsed.write_to_string()));
}
// Check that trailing characters are not ignored
@@ -113,7 +111,7 @@ fn test_locale_strict_cmp() {
for a in bcp47_strings.iter() {
for b in bcp47_strings.iter() {
let a_langid = a.parse::<Locale>().expect("Invalid BCP-47 in fixture");
- let a_normalized = a_langid.to_string();
+ let a_normalized = a_langid.write_to_string();
let string_cmp = a_normalized.as_bytes().cmp(b.as_bytes());
let test_cmp = a_langid.strict_cmp(b.as_bytes());
assert_eq!(string_cmp, test_cmp, "{:?}/{:?}", a, b);