Skip to content

Commit 65d656a

Browse files
committed
Add test case for partial ansi codes
Signed-off-by: phaer <[email protected]>
1 parent 2771b71 commit 65d656a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/reader.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,23 @@ mod tests {
404404
);
405405
}
406406

407+
#[test]
408+
fn test_skip_partial_ansi_code() {
409+
let f = io::Cursor::new("\x1b[31;1;4mHello\x1b[1");
410+
let mut r = NBReader::new(
411+
f,
412+
Options {
413+
timeout_ms: None,
414+
strip_ansi_escape_codes: true,
415+
},
416+
);
417+
let bytes = r
418+
.read_until(&ReadUntil::String("Hello".to_string()))
419+
.unwrap();
420+
assert_eq!(bytes, ("".to_string(), "Hello".to_string()));
421+
assert_eq!(None, r.try_read());
422+
}
423+
407424
#[test]
408425
fn test_skip_ansi_codes() {
409426
let f = io::Cursor::new("\x1b[31;1;4mHello\x1b[0m");

0 commit comments

Comments
 (0)