From 8b4e33220d3ca9a929e485388b73630883394fe6 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sun, 4 Apr 2021 11:55:30 -0600 Subject: add a test for suffix rule matching --- src/makefile/inference_rules.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs index ed83f03..7a636df 100644 --- a/src/makefile/inference_rules.rs +++ b/src/makefile/inference_rules.rs @@ -63,3 +63,18 @@ impl fmt::Display for InferenceRule { Ok(()) } } + +#[cfg(test)] +mod test { + use super::*; + + type R = eyre::Result<()>; + + #[test] + fn suffix_match() -> R { + let rule = InferenceRule::new_suffix(".o".to_string(), ".c".to_string(), vec![]); + assert!(rule.matches("foo.o")?); + assert!(rule.matches("dir/foo.o")?); + Ok(()) + } +} -- cgit v1.2.3