diff --git a/fuzz/src/bin/arrayish.rs b/fuzz/src/bin/arrayish.rs index 9fc5b30..53b2e27 100644 --- a/fuzz/src/bin/arrayish.rs +++ b/fuzz/src/bin/arrayish.rs @@ -26,11 +26,16 @@ arbitrary_stateful_operations! { fn insert(&mut self, index: usize, item: T); fn is_empty(&self) -> bool; fn len(&self) -> usize; + fn pop(&mut self) -> Option; fn push(&mut self, item: T); + fn remove(&mut self, index: usize) -> T; + fn resize(&mut self, new_len: usize, new_val: T); + fn swap_remove(&mut self, index: usize) -> T; fn truncate(&mut self, new_len: usize); } equal_with(Vec::from_iter) { + fn split_off(&mut self, at: usize) -> impl IntoIterator; fn drain(&self, range: R) -> impl Iterator; fn iter(&self) -> impl Iterator; fn iter_mut(&self) -> impl Iterator; @@ -39,13 +44,20 @@ arbitrary_stateful_operations! { pre { match self { - Self::insert { index, .. } if index > model.len() => { + Self::insert { index, .. } | Self::split_off { at: index } if index > model.len() => { + // TODO: Should test that these identically panic + return; + } + Self::remove { index } | Self::swap_remove { index } if index >= model.len() => { // TODO: Should test that these identically panic return; } Self::insert { .. } | Self::push { .. } if model.len() == CAPACITY => { return; } + Self::resize { new_len, .. } if new_len > CAPACITY => { + return; + } Self::drain { ref range } => { // TODO: Should test that these identically panic let start = match range.start_bound() { diff --git a/fuzz/src/bin/tinyvec.rs b/fuzz/src/bin/tinyvec.rs index 85d240e..1a66b69 100644 --- a/fuzz/src/bin/tinyvec.rs +++ b/fuzz/src/bin/tinyvec.rs @@ -26,11 +26,16 @@ arbitrary_stateful_operations! { fn insert(&mut self, index: usize, item: T); fn is_empty(&self) -> bool; fn len(&self) -> usize; + fn pop(&mut self) -> Option; fn push(&mut self, item: T); + fn remove(&mut self, index: usize) -> T; + fn resize(&mut self, new_len: usize, new_val: T); + fn swap_remove(&mut self, index: usize) -> T; fn truncate(&mut self, new_len: usize); } equal_with(Vec::from_iter) { + fn split_off(&mut self, at: usize) -> impl IntoIterator; fn drain(&self, range: R) -> impl Iterator; fn iter(&self) -> impl Iterator; fn iter_mut(&self) -> impl Iterator; @@ -39,10 +44,18 @@ arbitrary_stateful_operations! { pre { match self { - Self::insert { index, .. } if index > model.len() => { + Self::insert { index, .. } | Self::split_off { at: index } if index > model.len() => { // TODO: Should test that these identically panic return; } + Self::remove { index } | Self::swap_remove { index } if index >= model.len() => { + // TODO: Should test that these identically panic + return; + } + // Arbitrary limit to avoid allocating too large a buffer + Self::resize { new_len, .. } if new_len > 4 * CAPACITY => { + return; + } Self::drain { ref range } => { // TODO: Should test that these identically panic let start = match range.start_bound() {