]> git.lizzy.rs Git - rust.git/commitdiff
decrease false negatives for str overflow test
authorMichael Lamparski <diagonaldevice@gmail.com>
Mon, 30 Apr 2018 11:37:19 +0000 (07:37 -0400)
committerMichael Lamparski <diagonaldevice@gmail.com>
Mon, 30 Apr 2018 11:37:19 +0000 (07:37 -0400)
src/liballoc/tests/str.rs

index bfba9a6b3935568b50673d6ed72c2622a0723730..696ce79f3692063d3c2aff8639289c5f9eb06fbc 100644 (file)
@@ -602,7 +602,9 @@ mod overflow {
             mod rangeinclusive {
                 let DATA = "hello";
 
-                let BAD_INPUT = 1..=usize::max_value();
+                // note: using 0 specifically ensures that the result of overflowing is 0..0,
+                //       so that `get` doesn't simply return None for the wrong reason.
+                let BAD_INPUT = 0..=usize::max_value();
                 const EXPECT_MSG = "maximum usize";
 
                 !!generate_tests!!