Skip to content

Commit af7cfb4

Browse files
the8472Mark-Simulacrum
authored andcommitted
add test for failing io::copy specialization
1 parent b9438e0 commit af7cfb4

File tree

1 file changed

+18
-0
lines changed
  • library/std/src/sys/unix/kernel_copy

1 file changed

+18
-0
lines changed

library/std/src/sys/unix/kernel_copy/tests.rs

+18
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ fn copy_specialization() -> Result<()> {
6565
result.and(rm1).and(rm2)
6666
}
6767

68+
#[test]
69+
fn copies_append_mode_sink() -> Result<()> {
70+
let tmp_path = tmpdir();
71+
let source_path = tmp_path.join("copies_append_mode.source");
72+
let sink_path = tmp_path.join("copies_append_mode.sink");
73+
let mut source =
74+
OpenOptions::new().create(true).truncate(true).write(true).read(true).open(&source_path)?;
75+
write!(source, "not empty")?;
76+
source.seek(SeekFrom::Start(0))?;
77+
let mut sink = OpenOptions::new().create(true).append(true).open(&sink_path)?;
78+
79+
let copied = crate::io::copy(&mut source, &mut sink)?;
80+
81+
assert_eq!(copied, 9);
82+
83+
Ok(())
84+
}
85+
6886
#[bench]
6987
fn bench_file_to_file_copy(b: &mut test::Bencher) {
7088
const BYTES: usize = 128 * 1024;

0 commit comments

Comments
 (0)