about summary refs log tree commit diff
path: root/library/std/src/io/tests.rs
diff options
context:
space:
mode:
authorWilliam Venner <william@venner.io>2023-08-03 09:52:57 +0100
committerWilliam Venner <william@venner.io>2023-08-03 09:52:57 +0100
commit7c1ab71f71087d88aade79925ae68a447397422f (patch)
treeda115887b030619b0629e951de4a904357191e2e /library/std/src/io/tests.rs
parent1d7d7654e686f0452f10e016ef78c3d4b191526e (diff)
downloadrust-7c1ab71f71087d88aade79925ae68a447397422f.tar.gz
rust-7c1ab71f71087d88aade79925ae68a447397422f.zip
Add assertion to test `skip_until` return value
The extra `\0` in this commit is needed because the assertion on line 49 will fail otherwise (as `skip_until` stops reading on EOF and therefore does not read a trailing `\0`, returning 6 read bytes rather than the expected 7)
Diffstat (limited to 'library/std/src/io/tests.rs')
-rw-r--r--library/std/src/io/tests.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs
index 9a9a790d77d..4c5f86fe431 100644
--- a/library/std/src/io/tests.rs
+++ b/library/std/src/io/tests.rs
@@ -27,7 +27,7 @@ fn read_until() {
 
 #[test]
 fn skip_until() {
-    let bytes: &[u8] = b"read\0ignore\0read\0ignore\0read\0ignore";
+    let bytes: &[u8] = b"read\0ignore\0read\0ignore\0read\0ignore\0";
     let mut reader = BufReader::new(bytes);
 
     // read from the bytes, alternating between
@@ -41,10 +41,12 @@ fn skip_until() {
             break;
         } else {
             assert_eq!(out, b"read\0");
+            assert_eq!(read, b"read\0".len());
         }
 
         // skip past `ignore\0`
-        reader.skip_until(0).unwrap();
+        let skipped = reader.skip_until(0).unwrap();
+        assert_eq!(skipped, b"ignore\0".len());
     }
 
     // ensure we are at the end of the byte slice and that we can skip no further