Moves everything to a more rstest-style system of parameters, which is much cleaner than before.
S2444K42FJFLTQMMU6PAVA4YRQGDNCMIFBQ5VO2LCD4GJ7LUCRYQC
C6W7N6N57UCNHEV55HEZ3G7WN2ZOBGMFBB5M5ZPDB2HNNHHTOPBQC
AAERM7PBDVDFDEEXZ7UJ5WWQF7SPEJQQYXRBZ63ETB5YAVIECHMAC
XEEXWJLGVIPIGURSDU4ETZMGAIFTFDPECM4QWFOSRHU7GMGVOUVQC
6ABVDTXZOHVUDZDKDQS256F74LFIMM5DO3OZWHKRXZBUTPII4WAQC
7FYXVNAB6JAP3CJKE4MY57UWYSUPEXFVER6K264BSKYHVU6V4SGQC
3NMKD6I57ONAGHEN4PZIAV2KPYESVR4JL3DTWSHXKCMVJBEQ4GIQC
}
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 singular
1 => "You have 1 unread email.".to_string(),
// Everything else is plural
0 | 2.. => format!("You have {expected_plural} unread emails."),
},
"fr" => match unread_emails {
// Both 0 & 1 are singular
0 | 1 => format!("Vous avez {expected_plural} e-mail non lu."),
// Everything else is plural
2.. => format!("Vous avez {expected_plural} e-mails non lus."),
},
_ => unreachable!(),
}
}
}
}
#[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.")]