Skip to content

Commit 949bf9b

Browse files
committed
Use u8 test indices so quickcheck is likely to go out of bounds.
1 parent 54a48d2 commit 949bf9b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/quick.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,12 @@ quickcheck_limit! {
217217
})
218218
}
219219

220-
fn swap_indices(vec: Vec<u8>, a: usize, b: usize) -> TestResult {
220+
// Use `u8` test indices so quickcheck is likely to go out of bounds.
221+
fn swap_indices(vec: Vec<u8>, a: u8, b: u8) -> TestResult {
221222
let mut set = IndexSet::<u8>::from_iter(vec);
223+
let a = usize::from(a);
224+
let b = usize::from(b);
225+
222226
if a >= set.len() || b >= set.len() {
223227
return TestResult::discard();
224228
}
@@ -236,8 +240,12 @@ quickcheck_limit! {
236240
TestResult::passed()
237241
}
238242

239-
fn move_index(vec: Vec<u8>, from: usize, to: usize) -> TestResult {
243+
// Use `u8` test indices so quickcheck is likely to go out of bounds.
244+
fn move_index(vec: Vec<u8>, from: u8, to: u8) -> TestResult {
240245
let mut set = IndexSet::<u8>::from_iter(vec);
246+
let from = usize::from(from);
247+
let to = usize::from(to);
248+
241249
if from >= set.len() || to >= set.len() {
242250
return TestResult::discard();
243251
}

0 commit comments

Comments
 (0)