From fe8cfee6a02d49fb0331844fb4c7707e82701b11 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 4 May 2022 13:24:35 -0400 Subject: [PATCH] add tests for some Hint related methods --- parsing/src/suggestions.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/parsing/src/suggestions.rs b/parsing/src/suggestions.rs index 89202ce..008bc39 100644 --- a/parsing/src/suggestions.rs +++ b/parsing/src/suggestions.rs @@ -242,13 +242,13 @@ impl<'a> std::fmt::Debug for Hint<'a> { } impl<'a> Hint<'a> { - pub fn is_none(&self) -> bool { matches!(self, Hint::None) } + pub fn is_none(&self) -> bool { matches!(&self, &Hint::None) } #[allow(dead_code)] pub fn is_some(&self) -> bool { !self.is_none() } #[allow(dead_code)] - pub fn is_single(&self) -> bool { matches!(self, Hint::Single(_)) } + pub fn is_single(&self) -> bool { matches!(&self, &Hint::Single(_)) } } include!(concat!(env!("OUT_DIR"), "/codegen.rs")); @@ -338,4 +338,28 @@ mod tests { assert_eq!(super::split_function(key), value); } } + + #[test] + fn hint_tests() { + { + let hint = Hint::None; + assert!(hint.is_none()); + assert!(!hint.is_some()); + assert!(!hint.is_single()); + } + + { + let hint = Hint::Single(&""); + assert!(!hint.is_none()); + assert!(hint.is_some()); + assert!(hint.is_single()); + } + + { + let hint = Hint::Many(&[""]); + assert!(!hint.is_none()); + assert!(hint.is_some()); + assert!(!hint.is_single()); + } + } }