diff --git a/geo/src/utils.rs b/geo/src/utils.rs index 96f74b330..0b7eb0a95 100644 --- a/geo/src/utils.rs +++ b/geo/src/utils.rs @@ -65,9 +65,26 @@ pub fn partial_max(a: T, b: T) -> T { // The Rust standard library has `min` for `Ord`, but not for `PartialOrd` pub fn partial_min(a: T, b: T) -> T { - if a > b { + if a < b { a } else { b } } + +#[cfg(test)] +mod test { + use super::{partial_max, partial_min}; + + #[test] + fn test_partial_max() { + assert_eq!(5, partial_max(5, 4)); + assert_eq!(5, partial_max(5, 5)); + } + + #[test] + fn test_partial_min() { + assert_eq!(4, partial_min(5, 4)); + assert_eq!(4, partial_min(4, 4)); + } +}