aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/simple.rs
diff options
context:
space:
mode:
authorLibravatar vallentin <mail@vallentin.dev>2021-02-22 04:20:04 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-02-22 13:50:09 +0100
commitbfeaf5d6d8c1be478971c428734775cb9ef950c2 (patch)
treefbe413c18c9f150e7d22c0343e013c8d172fd7cf /testing/tests/simple.rs
parenta07a1d8b7b829ca0065e3026c05eec9b64e65e49 (diff)
downloadaskama-bfeaf5d6d8c1be478971c428734775cb9ef950c2.tar.gz
askama-bfeaf5d6d8c1be478971c428734775cb9ef950c2.tar.bz2
askama-bfeaf5d6d8c1be478971c428734775cb9ef950c2.zip
Added option test
Diffstat (limited to '')
-rw-r--r--testing/tests/simple.rs16
1 files changed, 16 insertions, 0 deletions
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
@@ -232,6 +232,22 @@ fn test_option() {
}
#[derive(Template)]
+#[template(source = "{{ Self::foo(None) }} {{ Self::foo(Some(1)) }}", ext = "txt")]
+struct OptionNoneSomeTemplate;
+
+impl OptionNoneSomeTemplate {
+ fn foo(x: Option<i32>) -> 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<T, U = u8>
where