From ed2e640dbdff88fe118d943fa0ea9ae00eb11555 Mon Sep 17 00:00:00 2001 From: Restioson Date: Tue, 24 Aug 2021 23:51:05 +0200 Subject: Add test case for matching on Option --- testing/tests/matches.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'testing/tests/matches.rs') diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs index c328e39..206cd1d 100644 --- a/testing/tests/matches.rs +++ b/testing/tests/matches.rs @@ -26,6 +26,24 @@ fn test_match_option() { assert_eq!(s.render().unwrap(), "\nNot Found\n"); } +#[derive(Template)] +#[template(path = "match-opt-bool.html")] +struct MatchOptBoolTemplate { + item: Option, +} + +#[test] +fn test_match_option_bool() { + let s = MatchOptBoolTemplate { item: Some(true) }; + assert_eq!(s.render().unwrap(), "\nFound Some(true)\n"); + + let s = MatchOptBoolTemplate { item: Some(false) }; + assert_eq!(s.render().unwrap(), "\nFound Some(false)\n"); + + let s = MatchOptBoolTemplate { item: None }; + assert_eq!(s.render().unwrap(), "\nNot Found\n"); +} + #[test] fn test_match_ref_deref() { let s = MatchOptRefTemplate { item: &Some("foo") }; -- cgit