diff options
| author | The8472 <git@infinite-source.de> | 2021-02-22 21:16:30 +0100 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-03-22 10:34:21 -0400 |
| commit | af7cfb4fefa383519cfbc1931ae5d87ae081196e (patch) | |
| tree | fb9ba6997990b579cc9d1007ea1313a2f37df098 | |
| parent | b9438e090570424d4f0813a94ce96be34351ae4d (diff) | |
add test for failing io::copy specialization
| -rw-r--r-- | library/std/src/sys/unix/kernel_copy/tests.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/kernel_copy/tests.rs b/library/std/src/sys/unix/kernel_copy/tests.rs index 77369cdd35f..3fe849e23e2 100644 --- a/library/std/src/sys/unix/kernel_copy/tests.rs +++ b/library/std/src/sys/unix/kernel_copy/tests.rs @@ -65,6 +65,24 @@ fn copy_specialization() -> Result<()> { result.and(rm1).and(rm2) } +#[test] +fn copies_append_mode_sink() -> Result<()> { + let tmp_path = tmpdir(); + let source_path = tmp_path.join("copies_append_mode.source"); + let sink_path = tmp_path.join("copies_append_mode.sink"); + let mut source = + OpenOptions::new().create(true).truncate(true).write(true).read(true).open(&source_path)?; + write!(source, "not empty")?; + source.seek(SeekFrom::Start(0))?; + let mut sink = OpenOptions::new().create(true).append(true).open(&sink_path)?; + + let copied = crate::io::copy(&mut source, &mut sink)?; + + assert_eq!(copied, 9); + + Ok(()) +} + #[bench] fn bench_file_to_file_copy(b: &mut test::Bencher) { const BYTES: usize = 128 * 1024; |
