aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mode.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-03 13:54:34 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-03 13:54:34 -0500
commit3fb01c1d74debdb4c8fd7395f7a2e0671dfac46b (patch)
treedacde910750bdbf072eecb9c4a6de1322f123235 /tests/mode.rs
parent7a915a84819ef52561306c74ec813f57974265d2 (diff)
downloadvt100-rust-3fb01c1d74debdb4c8fd7395f7a2e0671dfac46b.tar.gz
vt100-rust-3fb01c1d74debdb4c8fd7395f7a2e0671dfac46b.zip
clean up public api a bit
Diffstat (limited to 'tests/mode.rs')
-rw-r--r--tests/mode.rs343
1 files changed, 182 insertions, 161 deletions
diff --git a/tests/mode.rs b/tests/mode.rs
index d6807a9..2e10fee 100644
--- a/tests/mode.rs
+++ b/tests/mode.rs
@@ -3,276 +3,297 @@
#[test]
fn modes() {
let mut screen = vt100::Screen::new(24, 80);
- assert!(!screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(screen.mouse_protocol_mode(), vt100::MouseProtocolMode::None);
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?1h");
- assert!(!screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(screen.mouse_protocol_mode(), vt100::MouseProtocolMode::None);
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?9h");
- assert!(!screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::Press
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?25l");
- assert!(screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::Press
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?1000h");
- assert!(screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::PressRelease
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?1002h");
- assert!(screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::ButtonMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?1003h");
- assert!(screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?1005h");
- assert!(screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Utf8
+ );
screen.process(b"\x1b[?1006h");
- assert!(screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?2004h");
- assert!(screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b=");
- assert!(screen.hide_cursor());
assert!(screen.application_keypad());
assert!(screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?1l");
- assert!(screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?9l");
- assert!(screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?25h");
- assert!(!screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?1000l");
- assert!(!screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?1002l");
- assert!(!screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(
+ screen.mouse_protocol_mode(),
+ vt100::MouseProtocolMode::AnyMotion
+ );
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?1003l");
- assert!(!screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(screen.mouse_protocol_mode(), vt100::MouseProtocolMode::None);
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?1005l");
- assert!(!screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(screen.mouse_protocol_mode(), vt100::MouseProtocolMode::None);
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Sgr
+ );
screen.process(b"\x1b[?1006l");
- assert!(!screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(screen.bracketed_paste());
+ assert_eq!(screen.mouse_protocol_mode(), vt100::MouseProtocolMode::None);
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b[?2004l");
- assert!(!screen.hide_cursor());
assert!(screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(screen.mouse_protocol_mode(), vt100::MouseProtocolMode::None);
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
screen.process(b"\x1b>");
- assert!(!screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(!screen.application_cursor());
- assert!(!screen.mouse_reporting_press());
- assert!(!screen.mouse_reporting_press_release());
- assert!(!screen.mouse_reporting_button_motion());
- assert!(!screen.mouse_reporting_any_motion());
- assert!(!screen.mouse_reporting_utf8_mode());
- assert!(!screen.mouse_reporting_sgr_mode());
+ assert!(!screen.hide_cursor());
assert!(!screen.bracketed_paste());
+ assert_eq!(screen.mouse_protocol_mode(), vt100::MouseProtocolMode::None);
+ assert_eq!(
+ screen.mouse_protocol_encoding(),
+ vt100::MouseProtocolEncoding::Default
+ );
}
#[test]
@@ -287,12 +308,12 @@ fn alternate_buffer() {
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 0));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
screen.process(b"\x1b[m\x1b[2J\x1b[H1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24");
assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n");
assert_eq!(screen.cursor_position(), (23, 2));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
screen.process(b"\x1b[?47h");
assert_eq!(
@@ -300,7 +321,7 @@ fn alternate_buffer() {
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 0));
- assert!(screen.alternate_buffer_active());
+ assert!(screen.alternate_screen());
screen.process(b"foobar");
assert_eq!(
@@ -308,12 +329,12 @@ fn alternate_buffer() {
"foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 6));
- assert!(screen.alternate_buffer_active());
+ assert!(screen.alternate_screen());
screen.process(b"\x1b[?47l");
assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n");
assert_eq!(screen.cursor_position(), (23, 2));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
screen.process(b"\x1b[?47h");
assert_eq!(
@@ -321,12 +342,12 @@ fn alternate_buffer() {
"foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 6));
- assert!(screen.alternate_buffer_active());
+ assert!(screen.alternate_screen());
screen.process(b"\x1b[?47l");
assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n");
assert_eq!(screen.cursor_position(), (23, 2));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
// 1049
@@ -336,12 +357,12 @@ fn alternate_buffer() {
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 0));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
screen.process(b"\x1b[m\x1b[2J\x1b[H1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24");
assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n");
assert_eq!(screen.cursor_position(), (23, 2));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
screen.process(b"\x1b[?1049h");
assert_eq!(
@@ -349,7 +370,7 @@ fn alternate_buffer() {
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 0));
- assert!(screen.alternate_buffer_active());
+ assert!(screen.alternate_screen());
screen.process(b"foobar");
assert_eq!(
@@ -357,12 +378,12 @@ fn alternate_buffer() {
"foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 6));
- assert!(screen.alternate_buffer_active());
+ assert!(screen.alternate_screen());
screen.process(b"\x1b[?1049l");
assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n");
assert_eq!(screen.cursor_position(), (23, 2));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
screen.process(b"\x1b[?1049h");
assert_eq!(
@@ -370,10 +391,10 @@ fn alternate_buffer() {
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.cursor_position(), (0, 0));
- assert!(screen.alternate_buffer_active());
+ assert!(screen.alternate_screen());
screen.process(b"\x1b[?1049l");
assert_eq!(screen.window_contents(0, 0, 23, 79), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n");
assert_eq!(screen.cursor_position(), (23, 2));
- assert!(!screen.alternate_buffer_active());
+ assert!(!screen.alternate_screen());
}