From 5be6479f2c4fc68b9a62f9359dda673be76ada15 Mon Sep 17 00:00:00 2001 From: Qian Linfeng Date: Sat, 20 Oct 2018 13:46:48 +0800 Subject: Add test for unescaped variable expressions (see #132) --- testing/tests/simple.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'testing/tests') diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index e19b32e..d4d2964 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -30,6 +30,30 @@ fn test_variables() { assert_eq!(VariablesTemplate::extension(), Some("html")); } +#[derive(Template)] +#[template(path = "simple-no-escape.txt")] +struct VariablesTemplateNoEscape<'a> { + strvar: &'a str, + num: i64, + i18n: String, +} + +#[test] +fn test_variables_no_escape() { + let s = VariablesTemplateNoEscape { + strvar: "foo", + num: 42, + i18n: "Iñtërnâtiônàlizætiøn".to_string(), + }; + assert_eq!( + s.render().unwrap(), + "\nhello world, foo\n\ + with number: 42\n\ + Iñtërnâtiônàlizætiøn is important\n\ + in vars too: Iñtërnâtiônàlizætiøn" + ); +} + #[derive(Template)] #[template(path = "if.html")] struct IfTemplate { -- cgit