diff --git a/components/collator/README.md b/components/collator/README.md index 459c4ec9a04..f44fb3a03ca 100644 --- a/components/collator/README.md +++ b/components/collator/README.md @@ -204,8 +204,8 @@ let primary_and_case = &Default::default(), options).unwrap(); -assert_eq!(primary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Equal); -assert_eq!(primary_and_case.compare("dejavu", "dejAvu"), Ordering::Equal); +assert_eq!(primary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Less); +assert_eq!(primary_and_case.compare("dejavu", "dejAvu"), Ordering::Less); assert_eq!(primary_and_case.compare("dejavu", "déjavu"), Ordering::Equal); // Secondary with case level on @@ -217,8 +217,8 @@ let secondary_and_case = &Default::default(), options).unwrap(); -assert_eq!(secondary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Equal); -assert_eq!(secondary_and_case.compare("dejavu", "dejAvu"), Ordering::Equal); +assert_eq!(secondary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Less); +assert_eq!(secondary_and_case.compare("dejavu", "dejAvu"), Ordering::Less); assert_eq!(secondary_and_case.compare("dejavu", "déjavu"), Ordering::Less); // secondary difference // Tertiary diff --git a/components/collator/src/lib.rs b/components/collator/src/lib.rs index adcfef15a88..523f4f3cf10 100644 --- a/components/collator/src/lib.rs +++ b/components/collator/src/lib.rs @@ -226,8 +226,8 @@ //! &Default::default(), //! options).unwrap(); //! -//! assert_eq!(primary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Equal); -//! assert_eq!(primary_and_case.compare("dejavu", "dejAvu"), Ordering::Equal); +//! assert_eq!(primary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Less); +//! assert_eq!(primary_and_case.compare("dejavu", "dejAvu"), Ordering::Less); //! assert_eq!(primary_and_case.compare("dejavu", "déjavu"), Ordering::Equal); //! //! // Secondary with case level on @@ -239,8 +239,8 @@ //! &Default::default(), //! options).unwrap(); //! -//! assert_eq!(secondary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Equal); -//! assert_eq!(secondary_and_case.compare("dejavu", "dejAvu"), Ordering::Equal); +//! assert_eq!(secondary_and_case.compare("ⓓⓔⓐⓛ", "DEAL"), Ordering::Less); +//! assert_eq!(secondary_and_case.compare("dejavu", "dejAvu"), Ordering::Less); //! assert_eq!(secondary_and_case.compare("dejavu", "déjavu"), Ordering::Less); // secondary difference //! //! // Tertiary diff --git a/components/collator/src/options.rs b/components/collator/src/options.rs index fae093715e5..7d948b88938 100644 --- a/components/collator/src/options.rs +++ b/components/collator/src/options.rs @@ -510,7 +510,7 @@ impl CollatorOptionsBitField { if let Some(case_level) = case_level { self.0 |= CollatorOptionsBitField::EXPLICIT_CASE_LEVEL_MASK; if case_level { - self.0 |= CollatorOptionsBitField::ALTERNATE_HANDLING_MASK; + self.0 |= CollatorOptionsBitField::CASE_LEVEL_MASK; } } else { self.0 &= !CollatorOptionsBitField::EXPLICIT_CASE_LEVEL_MASK; diff --git a/components/collator/tests/tests.rs b/components/collator/tests/tests.rs index d96cf86d87a..15fc10296b5 100644 --- a/components/collator/tests/tests.rs +++ b/components/collator/tests/tests.rs @@ -1404,6 +1404,20 @@ fn test_conformance_non_ignorable() { } } +#[test] +fn test_case_level() { + let mut options = CollatorOptions::new(); + options.strength = Some(Strength::Primary); + options.case_level = Some(CaseLevel::On); + let collator_with_case = + Collator::try_new_unstable(&icu_testdata::unstable(), &Default::default(), options) + .unwrap(); + assert_eq!( + collator_with_case.compare("aA", "Aa"), + core::cmp::Ordering::Less + ); +} + // TODO: Test languages that map to the root. // The languages that map to root without script reordering are: // ca (at least for now)