Skip to content

Commit

Permalink
Check that the splitter is a subset of the universe.
Browse files Browse the repository at this point in the history
  • Loading branch information
jneem committed Feb 6, 2016
1 parent ffd3e14 commit 6728a22
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ impl Partition {
for &x in refiner.iter() {
if x >= self.rev_partition.len() {
panic!("`refiner` went out of bounds: {:?}", refiner);
} else if self.rev_partition[x] == usize::MAX {
panic!("`refiner contained an element ({:?}) that wasn't in the initial partition", x);
}

let part_idx = self.rev_partition[x];
if self.active_sets.insert(part_idx) {
// We start out saying that everything is in the difference (part \ refiner).
Expand Down Expand Up @@ -337,4 +340,11 @@ mod tests {
fn rest_refine_panics_on_out_of_bounds() {
Partition::simple(5).refine(&[1, 5]);
}

#[test]
#[should_panic]
fn rest_refine_panics_on_invalid_elt() {
let mut part = make(&[&[0, 1, 2, 4]], 5);
part.refine(&[0, 3]);
}
}

0 comments on commit 6728a22

Please sign in to comment.