Skip to content

Commit

Permalink
Add Range::is_disjoint() symmetry proptest
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Mar 13, 2024
1 parent 74f61fb commit 1965345
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,18 +939,6 @@ pub mod tests {
assert_eq!(r1.union(&r2).contains(&version), r1.contains(&version) || r2.contains(&version));
}

#[test]
fn is_disjoint_through_intersection(r1 in strategy(), r2 in strategy()) {
let disjoint_def = r1.intersection(&r2) == Range::empty();
assert_eq!(r1.is_disjoint(&r2), disjoint_def);
}

#[test]
fn subset_of_through_intersection(r1 in strategy(), r2 in strategy()) {
let disjoint_def = r1.intersection(&r2) == r1;
assert_eq!(r1.subset_of(&r2), disjoint_def);
}

#[test]
fn union_through_intersection(r1 in strategy(), r2 in strategy()) {
let union_def = r1
Expand Down Expand Up @@ -1024,6 +1012,27 @@ pub mod tests {
}
assert!(simp.segments.len() <= range.segments.len())
}

// Testing is_disjoint --------------------------------

#[test]
fn is_disjoint_through_intersection(r1 in strategy(), r2 in strategy()) {
let disjoint_def = r1.intersection(&r2) == Range::empty();
assert_eq!(r1.is_disjoint(&r2), disjoint_def);
}

#[test]
fn is_disjoint_symmetry(r1 in strategy(), r2 in strategy()) {
assert_eq!(r1.is_disjoint(&r2), r2.is_disjoint(&r1));
}

// Testing subset_of --------------------------------

#[test]
fn subset_of_through_intersection(r1 in strategy(), r2 in strategy()) {
let disjoint_def = r1.intersection(&r2) == r1;
assert_eq!(r1.subset_of(&r2), disjoint_def);
}
}

#[test]
Expand Down

0 comments on commit 1965345

Please sign in to comment.