| 42 | |
| 43 | #[test] |
| 44 | fn test_append() { |
| 45 | let tmpdir = tmpdir(); |
| 46 | let mut file = check!(tmpdir.create("file")); |
| 47 | check!(write!(file, "Hello")); |
| 48 | |
| 49 | let mut with_append = |
| 50 | check!(tmpdir.open_with("file", cap_fs_ext::OpenOptions::new().append(true))); |
| 51 | check!(write!(with_append, " world")); |
| 52 | |
| 53 | let mut for_read = check!(tmpdir.open("file")); |
| 54 | let mut s = String::new(); |
| 55 | check!(for_read.read_to_string(&mut s)); |
| 56 | assert_eq!(s, "Hello world"); |
| 57 | |
| 58 | check!(with_append.seek(SeekFrom::Start(0))); |
| 59 | check!(write!(with_append, "The quick brown fox")); |
| 60 | |
| 61 | let mut for_read = check!(tmpdir.open("file")); |
| 62 | let mut s = String::new(); |
| 63 | check!(for_read.read_to_string(&mut s)); |
| 64 | assert_eq!(s, "Hello worldThe quick brown fox"); |
| 65 | } |