| 429 | |
| 430 | #[test] |
| 431 | fn write_all_at() { |
| 432 | let dir = tempfile::tempdir().unwrap(); |
| 433 | let file = check!(OpenOptions::new() |
| 434 | .create_new(true) |
| 435 | .read(true) |
| 436 | .write(true) |
| 437 | .open(dir.path().join("file"))); |
| 438 | check!(write!(&file, "abcdefghijklmnopqrstuvwxyz")); |
| 439 | let buf0 = b"EFGHIJKL".to_vec(); |
| 440 | let buf1 = b"MNOPQRST".to_vec(); |
| 441 | check!(file.write_all_at(&buf0, 4)); |
| 442 | check!(file.write_all_at(&buf1, 12)); |
| 443 | assert_eq!(check!(file.stream_position()), 26); |
| 444 | let mut back = String::new(); |
| 445 | check!(file.seek(std::io::SeekFrom::Start(0))); |
| 446 | check!(file.read_to_string(&mut back)); |
| 447 | assert_eq!(back, "abcdEFGHIJKLMNOPQRSTuvwxyz"); |
| 448 | } |
| 449 | |
| 450 | #[test] |
| 451 | fn write_all_after_end() { |