diff options
| author | Kornel <kornel@geekhood.net> | 2024-02-21 15:56:50 +0000 |
|---|---|---|
| committer | Kornel <kornel@geekhood.net> | 2024-02-21 16:31:53 +0000 |
| commit | e49cd1c578227e450f0a703b08fa429e3931c228 (patch) | |
| tree | 44fdca08111610c5995d258be3d7b9546fd50b17 /library/std/src/io/tests.rs | |
| parent | 1d447a9946effc38c4b964a888ab408a3df3c246 (diff) | |
| download | rust-e49cd1c578227e450f0a703b08fa429e3931c228.tar.gz rust-e49cd1c578227e450f0a703b08fa429e3931c228.zip | |
TryReserveError to ErrorKind::OutOfMemory
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()); +} |
