Skip to content

Commit

Permalink
feat(src/inclusive_set.rs): quickcheck::Arbitrary for RangeInclusiveSet
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiderfelipe committed Nov 27, 2024
1 parent 47ef491 commit 5132684
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/inclusive_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ impl<T, StepFnsT> Default for RangeInclusiveSet<T, StepFnsT> {
}
}

#[cfg(feature = "quickcheck")]
impl<K> quickcheck::Arbitrary for RangeInclusiveSet<K>
where
K: quickcheck::Arbitrary + Ord + StepLite,
{
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
Self {
rm: RangeInclusiveMap::arbitrary(g),
}
}
}

impl<T> RangeInclusiveSet<T, T>
where
T: Ord + Clone + StepLite,
Expand Down Expand Up @@ -827,4 +839,11 @@ mod tests {
const _SET: RangeInclusiveSet<u32> = RangeInclusiveSet::new();
#[cfg(feature = "const_fn")]
const _SET2: RangeInclusiveSet<u32> = RangeInclusiveSet::new_with_step_fns();

#[cfg(feature = "quickcheck")]
quickcheck::quickcheck! {
fn prop(xs: RangeInclusiveSet<usize, usize>) -> bool {
xs == xs
}
}
}

0 comments on commit 5132684

Please sign in to comment.