Skip to content

Commit 4138c86

Browse files
committed
test: capture try_read panic on multi-byte input
1 parent f21a254 commit 4138c86

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/reader.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,4 +457,16 @@ mod tests {
457457
assert_eq!(None, r.try_read());
458458
assert_eq!(None, r.try_read());
459459
}
460+
461+
#[test]
462+
#[should_panic(expected = "is_char_boundary")]
463+
fn test_try_read_multibyte() {
464+
// Reproduces the char-boundary panic when the buffer holds a
465+
// multi-byte UTF-8 char. Filling `buffer` directly keeps the
466+
// test fully synchronous.
467+
let f = io::Cursor::new("");
468+
let mut r = NBReader::new(f, Options::default());
469+
r.buffer.push_str("\u{c3}\u{83}");
470+
let _ = r.try_read();
471+
}
460472
}

0 commit comments

Comments
 (0)