about summary refs log tree commit diff
path: root/library/std/src/io/tests.rs
diff options
context:
space:
mode:
authorBenoît du Garreau <bdgdlm@outlook.com>2023-06-12 18:17:48 +0200
committerBenoît du Garreau <bdgdlm@outlook.com>2023-07-26 23:31:03 +0200
commitebc59703292fd216d7ec1e027e0f3b78387a8ddf (patch)
tree0da9740047fae533ab96340679dda7bd17b8cdbc /library/std/src/io/tests.rs
parentcba6e102ec49d81086a780c12ef3a51f1c2bd340 (diff)
downloadrust-ebc59703292fd216d7ec1e027e0f3b78387a8ddf.tar.gz
rust-ebc59703292fd216d7ec1e027e0f3b78387a8ddf.zip
Add tests and comments about `read_to_string` and `read_line` specializations
Diffstat (limited to 'library/std/src/io/tests.rs')
-rw-r--r--library/std/src/io/tests.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs
index f4a886d889a..4a205f30d44 100644
--- a/library/std/src/io/tests.rs
+++ b/library/std/src/io/tests.rs
@@ -232,6 +232,17 @@ fn chain_bufread() {
 }
 
 #[test]
+fn chain_splitted_char() {
+    let chain = b"\xc3".chain(b"\xa9".as_slice());
+    assert_eq!(crate::io::read_to_string(chain).unwrap(), "é");
+
+    let mut chain = b"\xc3".chain(b"\xa9\n".as_slice());
+    let mut buf = String::new();
+    assert_eq!(chain.read_line(&mut buf).unwrap(), 3);
+    assert_eq!(buf, "é\n");
+}
+
+#[test]
 fn bufreader_size_hint() {
     let testdata = b"ABCDEFGHIJKL";
     let mut buf_reader = BufReader::new(&testdata[..]);