diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/icu_locid/tests/locale.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/icu_locid/tests/locale.rs | 16 |
1 files changed, 7 insertions, 9 deletions
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); |