From bfeaf5d6d8c1be478971c428734775cb9ef950c2 Mon Sep 17 00:00:00 2001 From: vallentin Date: Mon, 22 Feb 2021 04:20:04 +0100 Subject: Added option test --- 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 e7fca2c..b6dd31a 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -231,6 +231,22 @@ fn test_option() { assert_eq!(none.render().unwrap(), "none"); } +#[derive(Template)] +#[template(source = "{{ Self::foo(None) }} {{ Self::foo(Some(1)) }}", ext = "txt")] +struct OptionNoneSomeTemplate; + +impl OptionNoneSomeTemplate { + fn foo(x: Option) -> i32 { + x.unwrap_or_default() + } +} + +#[test] +fn test_option_none_some() { + let t = OptionNoneSomeTemplate; + assert_eq!(t.render().unwrap(), "0 1"); +} + #[derive(Template)] #[template(path = "generics.html")] struct GenericsTemplate -- cgit