mirror of
https://github.com/openharmony/third_party_rust_tinyvec.git
synced 2026-07-21 01:35:22 -04:00
Expand fuzzing coverage (#95)
* Also cover reserve, reserve_exact and shrink_to_fit by fuzzing. SmallVec had a use-after-free bug in shrink_to_fit inlining so we'd better test this * Also test extend_from_slice on tinyvec and arrayvec
This commit is contained in:
committed by
GitHub
parent
4c5fbbf907
commit
18af1a3959
@@ -26,6 +26,7 @@ arbitrary_stateful_operations! {
|
||||
fn as_slice(&self) -> &[T];
|
||||
fn clear(&mut self);
|
||||
fn dedup(&mut self);
|
||||
fn extend_from_slice(&mut self, sli: &Box<[T]>);
|
||||
fn insert(&mut self, index: usize, item: T);
|
||||
fn is_empty(&self) -> bool;
|
||||
fn len(&self) -> usize;
|
||||
@@ -56,7 +57,9 @@ arbitrary_stateful_operations! {
|
||||
Self::resize { new_len, .. } if new_len > CAPACITY => {
|
||||
return;
|
||||
}
|
||||
|
||||
Self::extend_from_slice { sli } if model.len().saturating_add(sli.len()) > CAPACITY => {
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -26,13 +26,17 @@ arbitrary_stateful_operations! {
|
||||
fn as_slice(&self) -> &[T];
|
||||
fn clear(&mut self);
|
||||
fn dedup(&mut self);
|
||||
fn extend_from_slice(&mut self, sli: &Box<[T]>);
|
||||
fn insert(&mut self, index: usize, item: T);
|
||||
fn is_empty(&self) -> bool;
|
||||
fn len(&self) -> usize;
|
||||
fn pop(&mut self) -> Option<T>;
|
||||
fn push(&mut self, item: T);
|
||||
fn remove(&mut self, index: usize) -> T;
|
||||
fn reserve(&mut self, n: usize);
|
||||
fn reserve_exact(&mut self, n: usize);
|
||||
fn resize(&mut self, new_len: usize, new_val: T);
|
||||
fn shrink_to_fit(&mut self);
|
||||
fn swap_remove(&mut self, index: usize) -> T;
|
||||
fn truncate(&mut self, new_len: usize);
|
||||
}
|
||||
@@ -50,7 +54,16 @@ arbitrary_stateful_operations! {
|
||||
// Arbitrary limit to avoid allocating too large a buffer
|
||||
Self::resize { new_len, .. } if new_len > 4 * CAPACITY => {
|
||||
return;
|
||||
}
|
||||
},
|
||||
Self::reserve { n } if model.capacity().saturating_add(n) > 4 * CAPACITY => {
|
||||
return;
|
||||
},
|
||||
Self::reserve_exact { n } if model.capacity().saturating_add(n) > 4 * CAPACITY => {
|
||||
return;
|
||||
},
|
||||
Self::extend_from_slice { sli } if model.len().saturating_add(sli.len()) > 4 * CAPACITY => {
|
||||
return;
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user