| 1 |
// This file is part of ICU4X. For terms of use, please see the file |
| 2 |
// called LICENSE at the top level of the ICU4X source tree |
| 3 |
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). |
| 4 |
|
| 5 |
use icu_locale_core::{data_locale, locale}; |
| 6 |
use icu_plurals::{PluralCategory, PluralRules, provider::PluralsCardinalV1}; |
| 7 |
use icu_provider::prelude::*; |
| 8 |
|
| 9 |
#[test] |
| 10 |
fn test_plural_rules() { |
| 11 |
assert_eq!( |
| 12 |
PluralRules::try_new(locale!("en").into(), Default::default()) |
| 13 |
.unwrap() |
| 14 |
.category_for(5_usize), |
| 15 |
PluralCategory::Other |
| 16 |
); |
| 17 |
} |
| 18 |
|
| 19 |
#[test] |
| 20 |
fn test_static_load_works() { |
| 21 |
DataProvider::<PluralsCardinalV1>::load( |
| 22 |
&icu_plurals::provider::Baked, |
| 23 |
DataRequest { |
| 24 |
id: DataIdentifierBorrowed::for_locale(&data_locale!("en")), |
| 25 |
..Default::default() |
| 26 |
}, |
| 27 |
) |
| 28 |
.expect("Failed to load payload"); |
| 29 |
} |
| 30 |
|
| 31 |
#[test] |
| 32 |
fn test_plural_category_all() { |
| 33 |
let categories: Vec<PluralCategory> = PluralCategory::all().collect(); |
| 34 |
|
| 35 |
assert_eq!(categories.len(), 6); |
| 36 |
|
| 37 |
assert_eq!(categories[0], PluralCategory::Few); |
| 38 |
assert_eq!(categories[1], PluralCategory::Many); |
| 39 |
assert_eq!(categories[2], PluralCategory::One); |
| 40 |
assert_eq!(categories[3], PluralCategory::Other); |
| 41 |
assert_eq!(categories[4], PluralCategory::Two); |
| 42 |
assert_eq!(categories[5], PluralCategory::Zero); |
| 43 |
} |