generics.rs
//! End-to-end test for generics support in the `l10n_embed_derive` macro
mod common;
use common::compare_message;
use icu_locale::{Locale, locale};
use l10n_embed_derive::localize;
const DEFAULT_LOCALE: Locale = locale!("en-US");
#[localize("tests/locale/**/basic.ftl")]
pub struct Greeting<T> {
name: T,
}
#[localize("tests/locale/**/basic.ftl")]
pub enum Message<T> {
Greeting { name: T },
}
#[test]
fn string() {
let name = "Ferris";
let expected = "Hello, Ferris!";
compare_message(Greeting { name }, expected, DEFAULT_LOCALE);
compare_message(Message::Greeting { name }, expected, DEFAULT_LOCALE);
}
#[test]
fn number() {
let name = 2;
let expected = "Hello, 2!";
compare_message(Greeting { name }, expected, DEFAULT_LOCALE);
compare_message(Message::Greeting { name }, expected, DEFAULT_LOCALE);
}