From 474d9d643661bdc0eeb09c58d3629e7cfe3e7324 Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Wed, 10 Jan 2024 13:26:25 +0800 Subject: [PATCH] add ut for `range_except` Signed-off-by: Richard Chien --- .../src/window_function/state/range_utils.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/expr/core/src/window_function/state/range_utils.rs b/src/expr/core/src/window_function/state/range_utils.rs index 256eb1ce1227a..d0dd07f223041 100644 --- a/src/expr/core/src/window_function/state/range_utils.rs +++ b/src/expr/core/src/window_function/state/range_utils.rs @@ -123,6 +123,25 @@ mod tests { use super::*; + #[test] + fn test_range_except() { + fn test(a: Range, b: Range, expected: impl IntoIterator) { + let (l, r) = range_except(a, b); + let set = l.into_iter().chain(r).collect::>(); + assert_eq!(set, expected.into_iter().collect()) + } + + test(0..0, 0..0, []); + test(0..1, 0..1, []); + test(0..1, 0..2, []); + test(1..2, 0..2, []); + test(0..2, 0..1, [1]); + test(0..2, 1..2, [0]); + test(0..5, 2..3, [0, 1, 3, 4]); + test(2..5, 1..3, [3, 4]); + test(2..5, 4..5, [2, 3]); + } + #[test] fn test_range_diff() { fn test(