From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- .../tests/fixtures/invalid-extensions.json | 40 ++++++++++++++++++ vendor/icu_locid/tests/fixtures/invalid.json | 49 ++++++++++++++++++++++ vendor/icu_locid/tests/fixtures/mod.rs | 1 + vendor/icu_locid/tests/langid.rs | 15 +++---- vendor/icu_locid/tests/locale.rs | 16 ++++--- 5 files changed, 105 insertions(+), 16 deletions(-) (limited to 'vendor/icu_locid/tests') 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,4 +1,53 @@ [ + { + "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": { 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 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) { } } 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::() .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) { 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) { 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::().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); -- cgit v1.2.3