Skip to content

Commit

Permalink
update signature for impls of Arbitrary
Browse files Browse the repository at this point in the history
  • Loading branch information
ziutech committed Aug 6, 2023
1 parent ce8c9bb commit 279fccf
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 24 deletions.
58 changes: 46 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ serde_ = { version = "1.0.114", default-features = false, optional = true, packa
[dev-dependencies]
lazy_static = "1.2"
rand = { version = "0.7.3", features = ["small_rng"] }
quickcheck = { version = "0.9", default-features = false }
quickcheck = { version = "1.0", default-features = false }
rayon_ = { version = "1.2.0", package = "rayon" }
serde_test = "1.0.114"
serde_json = "1.0.56"
Expand Down
22 changes: 11 additions & 11 deletions tests/quick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ impl<T> Arbitrary for Op<T>
where
T: Arbitrary,
{
fn arbitrary<G: Gen>(g: &mut G) -> Self {
match g.gen::<u32>() % 9 {
fn arbitrary(g: &mut Gen) -> Self {
match u32::arbitrary(g) % 9 {
0 | 1 => Push(T::arbitrary(g)),
2 => Pop,
3 => PopFront,
4 => SwapRemove(g.gen::<u16>()),
5 => Insert(g.gen::<u16>(), T::arbitrary(g)),
6 => Truncate(g.gen::<u8>()),
7 => Reserve(g.gen::<u8>()),
4 => SwapRemove(u16::arbitrary(g)),
5 => Insert(u16::arbitrary(g), T::arbitrary(g)),
6 => Truncate(u8::arbitrary(g)),
7 => Reserve(u8::arbitrary(g)),
8 => CheckEnds,
_ => unreachable!(),
}
Expand Down Expand Up @@ -221,12 +221,12 @@ impl Deref for Alpha {
const ALPHABET: &[u8] = b"abcdefghijklmnopqrstuvwxyz";

impl Arbitrary for Alpha {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let len = g.next_u32() % g.size() as u32;
fn arbitrary(g: &mut Gen) -> Self {
let len = u32::arbitrary(g) % g.size() as u32;
let len = min(len, 16);
Alpha(
(0..len)
.map(|_| ALPHABET[g.next_u32() as usize % ALPHABET.len()] as char)
.map(|_| ALPHABET[u32::arbitrary(g) as usize % ALPHABET.len()] as char)
.collect(),
)
}
Expand All @@ -251,8 +251,8 @@ impl<T> Arbitrary for Large<Vec<T>>
where
T: Arbitrary,
{
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let len = g.next_u32() % (g.size() * 10) as u32;
fn arbitrary(g: &mut Gen) -> Self {
let len = u32::arbitrary(g) % (g.size() * 10) as u32;
Large((0..len).map(|_| T::arbitrary(g)).collect())
}

Expand Down

0 comments on commit 279fccf

Please sign in to comment.