use proptest::collection;
use proptest::prelude::*;
use arenavec::region::{Arena, SliceVec};
use arenavec::ArenaBacking;
const DEFAULT_CAPACITY: usize = 4096 << 16;
#[derive(Clone, Debug)]
enum SliceVecOp {
Push(usize),
Resize(usize, usize),
Reserve(usize),
Delete,
Clone(usize),
}
prop_compose! {
fn arb_op(num_vecs: usize)
(id in 0..5,
size in 0..100,
val in 0..std::usize::MAX,
index in 0..num_vecs)
-> SliceVecOp
{
match id {
0 => SliceVecOp::Push(val),
1 => SliceVecOp::Resize(size as usize, val),
2 => SliceVecOp::Reserve(size as usize),
3 => SliceVecOp::Delete,
4 => SliceVecOp::Clone(index),
_ => unreachable!(),
}
}
}
prop_compose! {
fn arb_op_seq(num_vecs: usize, len: usize)
(ids in collection::vec(0..num_vecs, len),
ops in collection::vec(arb_op(num_vecs), len))
-> Vec<(usize, SliceVecOp)> {
let mut res = Vec::with_capacity(len);
for i in 0..len {
res.push((ids[i], ops[i].clone()));
}
res
}
}
const NUM_VECS: usize = 16;
fn rand_op_seq_inner(mut seq: Vec<(usize, SliceVecOp)>, filter: Option<&[usize]>) {
let arena = Arena::init_capacity(ArenaBacking::SystemAllocation, DEFAULT_CAPACITY).unwrap();
let token = arena.generation_token().unwrap();
let mut vecs: Vec