about summary refs log tree commit diff
path: root/library/std/src/io/copy
diff options
context:
space:
mode:
authorThe 8472 <git@infinite-source.de>2023-11-24 01:00:25 +0100
committerThe 8472 <git@infinite-source.de>2023-11-26 18:13:36 +0100
commitbc7dd5fa6d87d8a2826511a2e25aba976e4e1f25 (patch)
treed7c4251ad1bfbd013c5fa8a9280498b618683d7b /library/std/src/io/copy
parent820f06b21f8373060ff7b515715b8440a6a6c197 (diff)
unify read_to_end and io::copy impls for reading into a Vec
Diffstat (limited to 'library/std/src/io/copy')
-rw-r--r--library/std/src/io/copy/tests.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/library/std/src/io/copy/tests.rs b/library/std/src/io/copy/tests.rs
index af137eaf856..a1f909a3c53 100644
--- a/library/std/src/io/copy/tests.rs
+++ b/library/std/src/io/copy/tests.rs
@@ -82,13 +82,16 @@ fn copy_specializes_bufreader() {
 
 #[test]
 fn copy_specializes_to_vec() {
-    let cap = 123456;
-    let mut source = ShortReader { cap, observed_buffer: 0, read_size: 1337 };
+    let cap = DEFAULT_BUF_SIZE * 10;
+    let mut source = ShortReader { cap, observed_buffer: 0, read_size: DEFAULT_BUF_SIZE };
     let mut sink = Vec::new();
-    assert_eq!(cap as u64, io::copy(&mut source, &mut sink).unwrap());
+    let copied = io::copy(&mut source, &mut sink).unwrap();
+    assert_eq!(cap as u64, copied);
+    assert_eq!(sink.len() as u64, copied);
     assert!(
         source.observed_buffer > DEFAULT_BUF_SIZE,
-        "expected a large buffer to be provided to the reader"
+        "expected a large buffer to be provided to the reader, got {}",
+        source.observed_buffer
     );
 }