about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorThe8472 <git@infinite-source.de>2020-12-02 23:33:17 +0100
committerThe8472 <git@infinite-source.de>2020-12-02 23:34:59 +0100
commit9b390e73db26f17415dfeab2e49f13f04ad2474b (patch)
tree4b83dbccf81af9e4a5942e570a2dd46eba207a61 /library/std/src
parentaf69066aa6afa7bff771a6ee9548b2b84a02a88a (diff)
downloadrust-9b390e73db26f17415dfeab2e49f13f04ad2474b.tar.gz
rust-9b390e73db26f17415dfeab2e49f13f04ad2474b.zip
update test to check Take limits after copying
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/unix/kernel_copy/tests.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/kernel_copy/tests.rs b/library/std/src/sys/unix/kernel_copy/tests.rs
index 554ebd94022..79e99382591 100644
--- a/library/std/src/sys/unix/kernel_copy/tests.rs
+++ b/library/std/src/sys/unix/kernel_copy/tests.rs
@@ -42,8 +42,15 @@ fn copy_specialization() -> Result<()> {
         assert_eq!(sink.buffer(), b"wxyz");
 
         let copied = crate::io::copy(&mut source, &mut sink)?;
-        assert_eq!(copied, 10);
-        assert_eq!(sink.buffer().len(), 0);
+        assert_eq!(copied, 10, "copy obeyed limit imposed by Take");
+        assert_eq!(sink.buffer().len(), 0, "sink buffer was flushed");
+        assert_eq!(source.limit(), 0, "outer Take was exhausted");
+        assert_eq!(source.get_ref().buffer().len(), 0, "source buffer should be drained");
+        assert_eq!(
+            source.get_ref().get_ref().limit(),
+            1,
+            "inner Take allowed reading beyond end of file, some bytes should be left"
+        );
 
         let mut sink = sink.into_inner()?;
         sink.seek(SeekFrom::Start(0))?;