Skip to content

Commit 636ad62

Browse files
committed
Functional test of cloned file handle
1 parent eda35e1 commit 636ad62

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/run-pass/fs.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ fn main() {
4141
// Reading until EOF should get the whole text.
4242
file.read_to_end(&mut contents).unwrap();
4343
assert_eq!(bytes, contents.as_slice());
44-
// Cloning a file should be successful
45-
file.try_clone().unwrap();
44+
45+
// Cloning a file should be successful.
46+
let file = File::open(&path).unwrap();
47+
let mut cloned = file.try_clone().unwrap();
48+
// Reading from a cloned file should get the same text.
49+
let mut contents = Vec::new();
50+
cloned.read_to_end(&mut contents).unwrap();
51+
assert_eq!(bytes, contents.as_slice());
4652

4753
// Test that seeking to the beginning and reading until EOF gets the text again.
4854
file.seek(SeekFrom::Start(0)).unwrap();

0 commit comments

Comments
 (0)