From 636ad629f8dc0d803b5738c78fb0ad44efb767c9 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 30 Jan 2020 18:43:34 -0600 Subject: [PATCH] Functional test of cloned file handle --- tests/run-pass/fs.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/run-pass/fs.rs b/tests/run-pass/fs.rs index 632ed13f2ea..324630df1e9 100644 --- a/tests/run-pass/fs.rs +++ b/tests/run-pass/fs.rs @@ -41,8 +41,14 @@ fn main() { // Reading until EOF should get the whole text. file.read_to_end(&mut contents).unwrap(); assert_eq!(bytes, contents.as_slice()); - // Cloning a file should be successful - file.try_clone().unwrap(); + + // Cloning a file should be successful. + let file = File::open(&path).unwrap(); + let mut cloned = file.try_clone().unwrap(); + // Reading from a cloned file should get the same text. + let mut contents = Vec::new(); + cloned.read_to_end(&mut contents).unwrap(); + assert_eq!(bytes, contents.as_slice()); // Test that seeking to the beginning and reading until EOF gets the text again. file.seek(SeekFrom::Start(0)).unwrap(); -- 2.44.0