Skip to content

Commit

Permalink
add ut for range_except
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Chien <[email protected]>
  • Loading branch information
stdrc committed Jan 10, 2024
1 parent d00a704 commit 474d9d6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/expr/core/src/window_function/state/range_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ mod tests {

use super::*;

#[test]
fn test_range_except() {
fn test(a: Range<usize>, b: Range<usize>, expected: impl IntoIterator<Item = usize>) {
let (l, r) = range_except(a, b);
let set = l.into_iter().chain(r).collect::<HashSet<_>>();
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(
Expand Down

0 comments on commit 474d9d6

Please sign in to comment.