Skip to content

Commit 4e1a4dd

Browse files
committed
add ut for range_except
Signed-off-by: Richard Chien <[email protected]>
1 parent 9429d9d commit 4e1a4dd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/expr/core/src/window_function/state/range_utils.rs

+19
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@ mod tests {
123123

124124
use super::*;
125125

126+
#[test]
127+
fn test_range_except() {
128+
fn test(a: Range<usize>, b: Range<usize>, expected: impl IntoIterator<Item = usize>) {
129+
let (l, r) = range_except(a, b);
130+
let set = l.into_iter().chain(r).collect::<HashSet<_>>();
131+
assert_eq!(set, expected.into_iter().collect())
132+
}
133+
134+
test(0..0, 0..0, []);
135+
test(0..1, 0..1, []);
136+
test(0..1, 0..2, []);
137+
test(1..2, 0..2, []);
138+
test(0..2, 0..1, [1]);
139+
test(0..2, 1..2, [0]);
140+
test(0..5, 2..3, [0, 1, 3, 4]);
141+
test(2..5, 1..3, [3, 4]);
142+
test(2..5, 4..5, [2, 3]);
143+
}
144+
126145
#[test]
127146
fn test_range_diff() {
128147
fn test(

0 commit comments

Comments
 (0)