From a899561db2057b300176b704b92a4559d5895f68 Mon Sep 17 00:00:00 2001 From: bott Date: Sun, 11 Nov 2018 22:23:51 +0100 Subject: Add e2e test for escape --- testing/tests/simple.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'testing/tests') diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 2bf8e7a..7206add 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -30,6 +30,22 @@ fn test_variables() { assert_eq!(VariablesTemplate::extension(), Some("html")); } +#[derive(Template)] +#[template(path = "hello.html")] +struct EscapeTemplate<'a> { + name: &'a str, +} + +#[test] +fn test_escape() { + let s = EscapeTemplate { name: "<>&\"'/" }; + + assert_eq!( + s.render().unwrap(), + "Hello, <>&"'/!" + ); +} + #[derive(Template)] #[template(path = "simple-no-escape.txt")] struct VariablesTemplateNoEscape<'a> { -- cgit