pub struct DeltaDebugShrinker<T> { /* private fields */ }Expand description
Delta debugging shrinker for finding minimal failing subsets
Uses binary search to efficiently find the smallest subset of a collection that still fails a test. This is particularly useful for reducing sequences of operations or large inputs to their minimal failing case.
§Examples
use protest_extras::shrinking::DeltaDebugShrinker;
let items = vec!["a", "b", "c", "d", "e"];
let shrinker = DeltaDebugShrinker::new(items);
// Find minimal subset that contains "b" and "d"
let minimal = shrinker.find_minimal(|subset| {
subset.contains(&"b") && subset.contains(&"d")
});
assert_eq!(minimal, vec!["b", "d"]);Implementations§
Source§impl<T: Clone + Debug + PartialEq> DeltaDebugShrinker<T>
impl<T: Clone + Debug + PartialEq> DeltaDebugShrinker<T>
Sourcepub fn find_minimal<F>(self, predicate: F) -> Vec<T>
pub fn find_minimal<F>(self, predicate: F) -> Vec<T>
Find the minimal subset that satisfies the predicate
The predicate should return true for failing test cases.
Sourcepub fn shrink_steps<F>(self, predicate: F) -> DeltaDebugIterator<T, F> ⓘ
pub fn shrink_steps<F>(self, predicate: F) -> DeltaDebugIterator<T, F> ⓘ
Shrink to minimal subset, yielding intermediate results
This is useful if you want to see the shrinking process or stop early.
Trait Implementations§
Source§impl<T: Clone> Clone for DeltaDebugShrinker<T>
impl<T: Clone> Clone for DeltaDebugShrinker<T>
Auto Trait Implementations§
impl<T> Freeze for DeltaDebugShrinker<T>
impl<T> RefUnwindSafe for DeltaDebugShrinker<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for DeltaDebugShrinker<T>
impl<T> Sync for DeltaDebugShrinker<T>
impl<T> Unpin for DeltaDebugShrinker<T>
impl<T> UnsafeUnpin for DeltaDebugShrinker<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for DeltaDebugShrinker<T>where
Vec<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more