aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/reader.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/reader.rs b/src/reader.rs
index b08821f..a987b28 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -173,3 +173,23 @@ impl<'a, R: Read + 'a> IntoReader<'a> for BufReader<R> {
BufReadReader::new(self)
}
}
+
+#[cfg(test)]
+mod tests {
+ use std::io::{BufReader, ErrorKind};
+ use std::str::Utf8Error;
+
+ use super::{IntoReader, Reader};
+
+ #[test]
+ #[should_panic] // FIXME
+ fn buf_read_reader_invalid_utf8() {
+ let mut reader = BufReader::new(b" \xc3\x28" as &[u8]).into_reader();
+ assert_eq!(reader.read_char().unwrap(), Some(' '));
+ let error = reader.read_char().unwrap_err();
+ assert!(matches!(error.kind(), ErrorKind::InvalidData));
+ error.into_inner().unwrap().downcast::<Utf8Error>().unwrap();
+ assert_eq!(reader.read_char().unwrap(), Some('('));
+ assert_eq!(reader.read_char().unwrap(), None);
+ }
+}