From 48c6cd327d3c1df4218898be509250efcc56597c Mon Sep 17 00:00:00 2001 From: PizzasBear <43722034+PizzasBear@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:56:14 +0200 Subject: Enhance match to include multiple targets (#911) Signed-off-by: max --- testing/tests/matches.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'testing/tests/matches.rs') diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs index f5ccb95..4507489 100644 --- a/testing/tests/matches.rs +++ b/testing/tests/matches.rs @@ -195,3 +195,32 @@ fn test_match_with_comment() { let s = MatchWithComment { good: false }; assert_eq!(s.render().unwrap(), "bad"); } + +enum Suit { + Clubs, + Diamonds, + Hearts, + Spades, +} + +#[derive(Template)] +#[template(path = "match-enum-or.html")] +struct MatchEnumOrTemplate { + suit: Suit, +} + +#[test] +fn test_match_enum_or() { + let template = MatchEnumOrTemplate { suit: Suit::Clubs }; + assert_eq!(template.render().unwrap(), "The card is black\n"); + let template = MatchEnumOrTemplate { suit: Suit::Spades }; + assert_eq!(template.render().unwrap(), "The card is black\n"); + + let template = MatchEnumOrTemplate { suit: Suit::Hearts }; + assert_eq!(template.render().unwrap(), "The card is red\n"); + + let template = MatchEnumOrTemplate { + suit: Suit::Diamonds, + }; + assert_eq!(template.render().unwrap(), "The card is red\n"); +} -- cgit