diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/templates/literals.html | 1 | ||||
-rw-r--r-- | testing/templates/match-literal-char.html | 8 | ||||
-rw-r--r-- | testing/tests/matches.rs | 15 | ||||
-rw-r--r-- | testing/tests/simple.rs | 2 |
4 files changed, 25 insertions, 1 deletions
diff --git a/testing/templates/literals.html b/testing/templates/literals.html index 9d973bb..b5fb472 100644 --- a/testing/templates/literals.html +++ b/testing/templates/literals.html @@ -1,3 +1,4 @@ +{{ 'a' }} {{ "a" }} {{ true }} {{ false }} diff --git a/testing/templates/match-literal-char.html b/testing/templates/match-literal-char.html new file mode 100644 index 0000000..2ff255d --- /dev/null +++ b/testing/templates/match-literal-char.html @@ -0,0 +1,8 @@ +{% match item %} +{% when 'a' %} +Found literal a +{% when 'b' %} +Found literal b +{% else %} +Else found {{item}} +{% endmatch %} diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs index 3e6d636..811f3ce 100644 --- a/testing/tests/matches.rs +++ b/testing/tests/matches.rs @@ -48,6 +48,21 @@ fn test_match_literal() { } #[derive(Template)] +#[template(path = "match-literal-char.html")] +struct MatchLitCharTemplate { + item: char, +} + +#[test] +fn test_match_literal_char() { + let s = MatchLitCharTemplate { item: 'b' }; + assert_eq!(s.render().unwrap(), "\n\nFound literal b\n"); + + let s = MatchLitCharTemplate { item: 'c' }; + assert_eq!(s.render().unwrap(), "\n\nElse found c\n"); +} + +#[derive(Template)] #[template(path = "match-literal-num.html")] struct MatchLitNumTemplate { item: u32, diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 6dbfcfb..53f1122 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -119,7 +119,7 @@ struct LiteralsTemplate {} #[test] fn test_literals() { let s = LiteralsTemplate {}; - assert_eq!(s.render().unwrap(), "a\ntrue\nfalse"); + assert_eq!(s.render().unwrap(), "a\na\ntrue\nfalse"); } struct Holder { |