Refactor selectors test to not rely on funciton calls
Dependencies
- [2]
C6W7N6N5Implement `Localize` for `FixedDecimal` and primitive number types - [3]
CESJ4CTOMove macro-specific code into `macro_impl` module - [4]
7FYXVNABIgnore comments in Fluent source code - [5]
VNSHGQYNSupport using glob paths in `localize` macro - [6]
AAERM7PBAdd selector tests for the `fr` locale - [7]
6ABVDTXZImprove `fluent_embed_derive` test suite - [8]
XEEXWJLGAdd simple end-to-end test for selectors - [9]
3NMKD6I5Refactor `Localize` trait to use `std::io::Write`
Change contents
- replacement in fluent_embed_derive/tests/selectors.rs at line 4
use icu_locid::LanguageIdentifier;use icu_locid::{langid, LanguageIdentifier}; - edit in fluent_embed_derive/tests/selectors.rs at line 11[3.431]→[3.431:433](∅→∅),[3.614]→[3.614:615](∅→∅),[3.615]→[3.115:130](∅→∅),[3.130]→[2.0:56](∅→∅),[2.56]→[3.181:312](∅→∅),[3.181]→[3.181:312](∅→∅),[3.312]→[2.57:231](∅→∅),[2.231]→[3.562:627](∅→∅),[3.562]→[3.562:627](∅→∅),[3.627]→[2.232:418](∅→∅),[2.418]→[3.887:958](∅→∅),[3.887]→[3.887:958](∅→∅),[3.958]→[2.419:1419](∅→∅),[2.1419]→[3.958:974](∅→∅),[3.958]→[3.958:974](∅→∅)
}impl Message {fn expected_plural(&self, locale: &str) -> String {match self {Self::Emails { unread_emails } => match locale {"en-US" => match unread_emails {0..=999 => unread_emails.to_string(),&u64::MAX => "18,446,744,073,709,551,615".to_string(),_ => unreachable!(),},"fr" => match unread_emails {0..=999 => unread_emails.to_string(),&u64::MAX => "18 446 744 073 709 551 615".to_string(),_ => unreachable!(),},_ => unreachable!(),},}}fn expected_message(&self, locale: &str) -> String {match self {Self::Emails { unread_emails } => {let expected_plural = self.expected_plural(locale);match locale {"en-US" => match unread_emails {// Only 1 is singular1 => "You have 1 unread email.".to_string(),// Everything else is plural0 | 2.. => format!("You have {expected_plural} unread emails."),},"fr" => match unread_emails {// Both 0 & 1 are singular0 | 1 => format!("Vous avez {expected_plural} e-mail non lu."),// Everything else is plural2.. => format!("Vous avez {expected_plural} e-mails non lus."),},_ => unreachable!(),}}}} - edit in fluent_embed_derive/tests/selectors.rs at line 15
#[case::zero_en(langid!("en-US"), 0, "You have 0 unread emails.")]#[case::one_en(langid!("en-US"), 1, "You have 1 unread email.")]#[case::two_en(langid!("en-US"), 2, "You have 2 unread emails.")]#[case::max_en(langid!("en-US"),u64::MAX,"You have 18,446,744,073,709,551,615 unread emails.")]#[case::zero_fr(langid!("fr"), 0, "Vous avez 0 e-mail non lu.")]#[case::one_fr(langid!("fr"), 1, "Vous avez 1 e-mail non lu.")]#[case::two_fr(langid!("fr"), 2, "Vous avez 2 e-mails non lus.")]#[case::max_fr(langid!("fr"), u64::MAX, "Vous avez 18 446 744 073 709 551 615 e-mails non lus.")] - replacement in fluent_embed_derive/tests/selectors.rs at line 28
#[values(0, 1, 2, u64::MAX)] unread_emails: u64,#[values("en-US", "fr")] locale: &str,#[case] locale: LanguageIdentifier,#[case] unread_emails: u64,#[case] expected_message: String, - edit in fluent_embed_derive/tests/selectors.rs at line 33
let language_id = LanguageIdentifier::try_from_bytes(locale.as_bytes()).unwrap();// Make sure the generated string is what we expectlet expected_message = data.expected_message(locale); - replacement in fluent_embed_derive/tests/selectors.rs at line 34
data.message_for_locale(&mut buffer, &language_id).unwrap();data.message_for_locale(&mut buffer, &locale).unwrap();