Skip to content

Commit

Permalink
Add test for infinitely looping cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gandalf3 authored and uttarayan21 committed Mar 16, 2023
1 parent 0f2ace5 commit 8a59123
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,27 @@ fn test_screen_modes() {
assert_eq!(bytes.into_text(), output);
}

#[test]
fn test_cursor_shape_and_color() {
let bytes: Vec<u8> = b"\x1b[4 q\x1b]12;#fab1ed\x07".to_vec();
let output = Ok(Text::from(Spans::from(Span::styled("", Style::default()))));
assert_eq!(bytes.into_text(), output);
}

#[test]
fn test_malformed_simple() {
let bytes: Vec<u8> = b"\x1b[".to_vec();
let output = Ok(Text::from(Spans::from(Span::styled("", Style::default()))));
assert_eq!(bytes.into_text(), output);
}

#[test]
fn test_malformed_complex() {
let bytes: Vec<u8> = b"\x1b\x1b[0\x1b[m\x1b".to_vec();
let output = Ok(Text::from(Spans::from(Span::styled("", Style::default()))));
assert_eq!(bytes.into_text(), output);
}

fn some_text(s: &'static str) -> Result<Text<'static>, ansi_to_tui::Error> {
Ok(Text {
lines: vec![Spans(vec![Span {
Expand All @@ -158,4 +179,3 @@ fn some_text(s: &'static str) -> Result<Text<'static>, ansi_to_tui::Error> {
}])],
})
}

0 comments on commit 8a59123

Please sign in to comment.