mirror of
https://github.com/openharmony/third_party_rust_tinyvec.git
synced 2026-07-18 12:25:35 -04:00
Extend methods run through arbitrary-model-tests
This commit is contained in:
@@ -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<T>;
|
||||
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<Item = T>;
|
||||
fn drain(&self, range: R) -> impl Iterator<Item = T>;
|
||||
fn iter(&self) -> impl Iterator<Item = &T>;
|
||||
fn iter_mut(&self) -> impl Iterator<Item = &mut T>;
|
||||
@@ -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() {
|
||||
|
||||
+14
-1
@@ -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<T>;
|
||||
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<Item = T>;
|
||||
fn drain(&self, range: R) -> impl Iterator<Item = T>;
|
||||
fn iter(&self) -> impl Iterator<Item = &T>;
|
||||
fn iter_mut(&self) -> impl Iterator<Item = &mut T>;
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user