diff options
Diffstat (limited to 'library/std/src/io/tests.rs')
| -rw-r--r-- | library/std/src/io/tests.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs index 5396f7f6e21..c306de3039f 100644 --- a/library/std/src/io/tests.rs +++ b/library/std/src/io/tests.rs @@ -692,3 +692,13 @@ fn read_buf_full_read() { assert_eq!(BufReader::new(FullRead).fill_buf().unwrap().len(), DEFAULT_BUF_SIZE); } + +#[test] +// 64-bit only to be sure the allocator will fail fast on an impossible to satsify size +#[cfg(target_pointer_width = "64")] +fn try_oom_error() { + let mut v = Vec::<u8>::new(); + let reserve_err = v.try_reserve(isize::MAX as usize - 1).unwrap_err(); + let io_err = io::Error::from(reserve_err); + assert_eq!(io::ErrorKind::OutOfMemory, io_err.kind()); +} |
