Skip to content

Commit 3514c06

Browse files
committed
third attempt
1 parent cd4c837 commit 3514c06

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/map.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8045,35 +8045,34 @@ mod test_map {
80458045
use crate::TryReserveError::{AllocError, CapacityOverflow};
80468046

80478047
const MAX_ISIZE: usize = isize::MAX as usize;
8048-
const GROUP_WIDTH: usize = 128;
80498048

80508049
let mut empty_bytes: HashMap<u8, u8> = HashMap::new();
80518050

80528051
if let Err(CapacityOverflow) = empty_bytes.try_reserve(usize::MAX) {
80538052
} else {
8054-
panic!("isize::MAX should trigger an overflow!");
8053+
panic!("usize::MAX should trigger an overflow!");
80558054
}
80568055

80578056
if let Err(CapacityOverflow) = empty_bytes.try_reserve(MAX_ISIZE) {
80588057
} else {
80598058
panic!("isize::MAX should trigger an overflow!");
80608059
}
80618060

8062-
if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_ISIZE / 24 - (GROUP_WIDTH + 1))
8061+
if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_ISIZE / 5)
80638062
{
80648063
} else {
80658064
// This may succeed if there is enough free memory. Attempt to
80668065
// allocate a few more hashmaps to ensure the allocation will fail.
80678066
let mut empty_bytes2: HashMap<u8, u8> = HashMap::new();
8068-
let _ = empty_bytes2.try_reserve(MAX_ISIZE / 24 - (GROUP_WIDTH + 1));
8067+
let _ = empty_bytes2.try_reserve(MAX_ISIZE / 5);
80698068
let mut empty_bytes3: HashMap<u8, u8> = HashMap::new();
8070-
let _ = empty_bytes3.try_reserve(MAX_ISIZE / 24 - (GROUP_WIDTH + 1));
8069+
let _ = empty_bytes3.try_reserve(MAX_ISIZE / 5);
80718070
let mut empty_bytes4: HashMap<u8, u8> = HashMap::new();
80728071
if let Err(AllocError { .. }) =
8073-
empty_bytes4.try_reserve(MAX_ISIZE / 24 - (GROUP_WIDTH + 1))
8072+
empty_bytes4.try_reserve(MAX_ISIZE / 5)
80748073
{
80758074
} else {
8076-
panic!("isize::MAX / 24 should trigger an OOM!");
8075+
panic!("isize::MAX / 5 should trigger an OOM!");
80778076
}
80788077
}
80798078
}

0 commit comments

Comments
 (0)