Skip to content

Commit

Permalink
add tests for duplicated and/or overlapping intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
bguo068 committed Jun 3, 2024
1 parent eb609f8 commit 10527aa
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/test_fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,23 @@ mod keep_intervals {

#[test]
fn test_keep_intervals() {
// tests for invalid intervals
let intervals_lst = vec![
vec![(1001.0, 1002.0)], // > seqlen
vec![(20.0, 10.0)], // out of order
vec![(10.0, 20.0), (19.0, 30.0)], // overlapping intervals
];
for intervals in intervals_lst {
let mut tables = TableCollection::new(100.0).unwrap();
tables.build_index().unwrap();
let opts = TreeSequenceFlags::default();
let trees = TreeSequence::new(tables, opts).unwrap();
let res = trees.keep_intervals(intervals.into_iter(), true);
assert!(res.is_err());
}

// tests for valid intervals
let intervals_lst = vec![
vec![(1001.0, 1002.0)], // out of range: > seqlen
vec![(10.0, 20.0), (700.0, 850.0)], // multiple intervals
vec![(10.0, 20.0)], // single intervals
];
Expand Down

0 comments on commit 10527aa

Please sign in to comment.