diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-18 16:04:27 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-18 16:04:27 +0100 |
commit | 8b5d59af62fe650d7c0e79f2086002fae4942629 (patch) | |
tree | ee2227e19426a7c8f63f4463300ff3480143fc7f /testing/tests/simple.rs | |
parent | dbc0c8998b904855ba61ed0c47afc9b5d8ab6afa (diff) | |
download | askama-8b5d59af62fe650d7c0e79f2086002fae4942629.tar.gz askama-8b5d59af62fe650d7c0e79f2086002fae4942629.tar.bz2 askama-8b5d59af62fe650d7c0e79f2086002fae4942629.zip |
Add test for handling Option types (with method calls)
Diffstat (limited to 'testing/tests/simple.rs')
-rw-r--r-- | testing/tests/simple.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 00acda5..8e5c85a 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -107,3 +107,18 @@ fn test_attr() { let t = AttrTemplate { inner: Holder { a: 5 } }; assert_eq!(t.render(), "5\n"); } + + +#[derive(Template)] +#[template(path = "option.html")] +struct OptionTemplate<'a> { + var: Option<&'a str>, +} + +#[test] +fn test_option() { + let some = OptionTemplate { var: Some("foo") }; + assert_eq!(some.render(), "some: foo\n"); + let none = OptionTemplate { var: None }; + assert_eq!(none.render(), "none\n"); +} |