Skip to content

Commit 02b3da1

Browse files
committed
decrease false negatives for str overflow test
1 parent ce66f5d commit 02b3da1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/liballoc/tests/str.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ mod slice_index {
602602
mod rangeinclusive {
603603
let DATA = "hello";
604604

605-
let BAD_INPUT = 1..=usize::max_value();
605+
// note: using 0 specifically ensures that the result of overflowing is 0..0,
606+
// so that `get` doesn't simply return None for the wrong reason.
607+
let BAD_INPUT = 0..=usize::max_value();
606608
const EXPECT_MSG = "maximum usize";
607609

608610
!!generate_tests!!

0 commit comments

Comments
 (0)