From 8d1aece508b76497daa04a90c00967b543d1741b Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Jun 2020 01:11:51 +0200 Subject: add tests for CompOp::matches --- src/filters/values.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/filters') diff --git a/src/filters/values.rs b/src/filters/values.rs index 3109ef4..141aecd 100644 --- a/src/filters/values.rs +++ b/src/filters/values.rs @@ -193,3 +193,31 @@ impl Producer for DurationProducer { pub fn duration() -> Box> { Box::new(DurationProducer) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_compop_matches() { + assert!(CompOp::Less.matches(Ordering::Less)); + assert!(!CompOp::Less.matches(Ordering::Equal)); + assert!(!CompOp::Less.matches(Ordering::Greater)); + + assert!(CompOp::LessEqual.matches(Ordering::Less)); + assert!(CompOp::LessEqual.matches(Ordering::Equal)); + assert!(!CompOp::LessEqual.matches(Ordering::Greater)); + + assert!(!CompOp::Equal.matches(Ordering::Less)); + assert!(CompOp::Equal.matches(Ordering::Equal)); + assert!(!CompOp::Equal.matches(Ordering::Greater)); + + assert!(!CompOp::GreaterEqual.matches(Ordering::Less)); + assert!(CompOp::GreaterEqual.matches(Ordering::Equal)); + assert!(CompOp::GreaterEqual.matches(Ordering::Greater)); + + assert!(!CompOp::Greater.matches(Ordering::Less)); + assert!(!CompOp::Greater.matches(Ordering::Equal)); + assert!(CompOp::Greater.matches(Ordering::Greater)); + } +} -- cgit v1.2.3