From 80148aa75335563106abae8680197e4adf3eb2eb Mon Sep 17 00:00:00 2001 From: Tuomas Siipola Date: Sun, 12 Jan 2020 00:47:52 +0200 Subject: Support escaping in string literals Do not attempt to parse escape sequences thoroughly. Instead let the Rust compiler to check the string literals and provide nice error messages if necessary. --- testing/tests/simple.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'testing/tests/simple.rs') diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 53f1122..a075d26 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -122,6 +122,19 @@ fn test_literals() { assert_eq!(s.render().unwrap(), "a\na\ntrue\nfalse"); } +#[derive(Template)] +#[template(path = "literals-escape.html")] +struct LiteralsEscapeTemplate {} + +#[test] +fn test_literals_escape() { + let s = LiteralsEscapeTemplate {}; + assert_eq!( + s.render().unwrap(), + "A\n\r\t\\\0♥'""\nA\n\r\t\\\0♥'"'" + ); +} + struct Holder { a: usize, } -- cgit