diff options
author | Anthony Nowell <anowell@gmail.com> | 2017-10-05 21:59:51 -0600 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-11-02 15:01:10 +0100 |
commit | 89a90eb46c822957af5b6aef8615a7d7398e7de4 (patch) | |
tree | 3a5faf88d0276e3de82f2ee4e344a1c08dc171af /testing/tests | |
parent | cc51d201ab9e7ba958363d1f74b7bfd4dd12fecf (diff) | |
download | askama-89a90eb46c822957af5b6aef8615a7d7398e7de4.tar.gz askama-89a90eb46c822957af5b6aef8615a7d7398e7de4.tar.bz2 askama-89a90eb46c822957af5b6aef8615a7d7398e7de4.zip |
Make match ref/deref as needed
Much of this can be yanked out and made simpler
when match-modes lands in stable
Diffstat (limited to '')
-rw-r--r-- | testing/tests/matches.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs index 4f159ab..b8a6c98 100644 --- a/testing/tests/matches.rs +++ b/testing/tests/matches.rs @@ -9,6 +9,13 @@ struct MatchOptTemplate<'a> { item: Option<&'a str>, } +#[derive(Template)] +#[template(path = "match-opt.html")] +struct MatchOptRefTemplate<'a> { + item: &'a Option<&'a str>, +} + + #[test] fn test_match_option() { let s = MatchOptTemplate { item: Some("foo") }; @@ -21,6 +28,11 @@ fn test_match_option() { assert_eq!(s.render().unwrap(), "\n\nNot Found\n"); } +#[test] +fn test_match_ref_deref() { + let s = MatchOptRefTemplate { item: &Some("foo") }; + assert_eq!(s.render().unwrap(), "\n\nFound literal foo\n"); +} #[derive(Template)] #[template(path = "match-literal.html")] @@ -36,3 +48,18 @@ fn test_match_literal() { let s = MatchLitTemplate { item: "qux" }; assert_eq!(s.render().unwrap(), "\n\nElse found qux\n"); } + +#[derive(Template)] +#[template(path = "match-literal-num.html")] +struct MatchLitNumTemplate { + item: u32, +} + +#[test] +fn test_match_literal_num() { + let s = MatchLitNumTemplate { item: 42 }; + assert_eq!(s.render().unwrap(), "\n\nFound answer to everything\n"); + + let s = MatchLitNumTemplate { item: 23 }; + assert_eq!(s.render().unwrap(), "\n\nElse found 23\n"); +} |