| 1 | use super::*; |
| 2 | use std::io::{Error, ErrorKind}; |
| 3 | |
| 4 | #[test] |
| 5 | fn storage_full_is_distinct_from_other_io_errors() { |
| 6 | assert_eq!(io_error(ErrorKind::StorageFull.into()), ErrorCode::DiskFull); |
| 7 | for kind in [ |
| 8 | ErrorKind::PermissionDenied, |
| 9 | ErrorKind::Other, |
| 10 | ErrorKind::NotFound, |
| 11 | ] { |
| 12 | assert_eq!(io_error(kind.into()), ErrorCode::Io); |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | #[cfg(target_os = "linux")] |
| 17 | #[test] |
| 18 | fn native_linux_enospc_is_disk_full() { |
| 19 | assert_eq!(io_error(Error::from_raw_os_error(28)), ErrorCode::DiskFull); |
| 20 | for code in [5, 13, 39, 112] { |
| 21 | assert_eq!(io_error(Error::from_raw_os_error(code)), ErrorCode::Io); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | #[cfg(windows)] |
| 26 | #[test] |
| 27 | fn native_windows_disk_full_codes_are_distinct_from_access_denied() { |
| 28 | for code in [39, 112] { |
| 29 | assert_eq!( |
| 30 | io_error(Error::from_raw_os_error(code)), |
| 31 | ErrorCode::DiskFull |
| 32 | ); |
| 33 | } |
| 34 | assert_eq!(io_error(Error::from_raw_os_error(5)), ErrorCode::Io); |
| 35 | } |