diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-08 03:35:44 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-08 03:38:00 -0500 |
commit | ac6aa6cb1659dd716701e2af41756ed3fe5faf0d (patch) | |
tree | 421d104e9590e846c8990b6ff5777f9dd59b82cf /tests | |
parent | 484e4439a7984dd55d46eb432f5b7822b12b2c4a (diff) | |
download | vt100-rust-ac6aa6cb1659dd716701e2af41756ed3fe5faf0d.tar.gz vt100-rust-ac6aa6cb1659dd716701e2af41756ed3fe5faf0d.zip |
clearing cells sets the background color
Diffstat (limited to 'tests')
-rw-r--r-- | tests/csi.rs | 284 |
1 files changed, 284 insertions, 0 deletions
diff --git a/tests/csi.rs b/tests/csi.rs index 1310dac..e0cfa39 100644 --- a/tests/csi.rs +++ b/tests/csi.rs @@ -88,6 +88,7 @@ fn relative_movement() { assert_eq!(parser.screen().cursor_position(), (0, 0)); } +#[allow(clippy::cognitive_complexity)] #[test] fn ed() { let mut parser = vt100::Parser::new(24, 80); @@ -155,8 +156,167 @@ fn ed() { parser.screen().contents(), "foo\n\n\n\n bar\n\n\n\n\n ba" ); + + parser.process(b"\x1bc\x1b[5;5H"); + assert_eq!( + parser.screen().cell(3, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(5, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + b"\x1b[?25h\x1b[H\x1b[J\x1b[5;5H" + ); + + parser.process(b"\x1b[41m\x1b[J"); + assert_eq!( + parser.screen().cell(3, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(5, 5).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().contents_formatted(), + format!( + "\x1b[?25h\x1b[H\x1b[J{}{}\x1b[41m{}\r\n{}{}\x1b[5;5H", + "\r\n".repeat(4), + "\x1b[C".repeat(4), + "\x1b[X\x1b[C".repeat(76), + format!("{}\r\n", "\x1b[X\x1b[C".repeat(80)).repeat(18), + "\x1b[X\x1b[C".repeat(80), + ) + .as_bytes() + ); + + parser.process(b"\x1bc\x1b[5;5H"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + b"\x1b[?25h\x1b[H\x1b[J\x1b[5;5H" + ); + + parser.process(b"\x1b[41m\x1b[1J"); + assert_eq!( + parser.screen().cell(3, 3).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(5, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + format!( + "\x1b[?25h\x1b[H\x1b[J\x1b[41m{}{}\x1b[5;5H", + format!("{}\r\n", "\x1b[X\x1b[C".repeat(80)).repeat(4), + "\x1b[X\x1b[C".repeat(5), + ) + .as_bytes() + ); + + parser.process(b"\x1bc\x1b[5;5H"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + b"\x1b[?25h\x1b[H\x1b[J\x1b[5;5H" + ); + + parser.process(b"\x1b[41m\x1b[2J"); + assert_eq!( + parser.screen().cell(3, 3).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(5, 5).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().contents_formatted(), + format!( + "\x1b[?25h\x1b[H\x1b[J\x1b[41m{}{}\x1b[5;5H", + format!("{}\r\n", "\x1b[X\x1b[C".repeat(80)).repeat(23), + "\x1b[X\x1b[C".repeat(80), + ) + .as_bytes() + ); } +#[allow(clippy::cognitive_complexity)] #[test] fn el() { let mut parser = vt100::Parser::new(24, 80); @@ -227,6 +387,130 @@ fn el() { parser.screen().contents(), " 1234567890\n12345678901234567890" ); + + parser.process(b"\x1bc\x1b[5;5H"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + b"\x1b[?25h\x1b[H\x1b[J\x1b[5;5H" + ); + + parser.process(b"\x1b[41m\x1b[K"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().contents_formatted(), + format!( + "\x1b[?25h\x1b[H\x1b[J{}{}\x1b[41m{}\x1b[5;5H", + "\r\n".repeat(4), + "\x1b[C".repeat(4), + "\x1b[X\x1b[C".repeat(76) + ) + .as_bytes() + ); + + parser.process(b"\x1bc\x1b[5;5H"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + b"\x1b[?25h\x1b[H\x1b[J\x1b[5;5H" + ); + + parser.process(b"\x1b[41m\x1b[1K"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + format!( + "\x1b[?25h\x1b[H\x1b[J{}\x1b[41m{}\x1b[5;5H", + "\r\n".repeat(4), + "\x1b[X\x1b[C".repeat(5), + ) + .as_bytes() + ); + + parser.process(b"\x1bc\x1b[5;5H"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Default + ); + assert_eq!( + parser.screen().contents_formatted(), + b"\x1b[?25h\x1b[H\x1b[J\x1b[5;5H" + ); + + parser.process(b"\x1b[41m\x1b[2K"); + assert_eq!( + parser.screen().cell(4, 3).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 4).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().cell(4, 5).unwrap().bgcolor(), + vt100::Color::Idx(1) + ); + assert_eq!( + parser.screen().contents_formatted(), + format!( + "\x1b[?25h\x1b[H\x1b[J{}\x1b[41m{}\x1b[5;5H", + "\r\n".repeat(4), + "\x1b[X\x1b[C".repeat(80), + ) + .as_bytes() + ); } #[test] |