diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-29 14:24:28 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-29 14:24:28 -0400 |
commit | 267f7452949617375c8570caf4b03b434e3350e8 (patch) | |
tree | 517ba3be3617c8ca60e804b1e033388e069c37b0 /tests/processing.rs | |
parent | f84638fd816d2295c5d9f60c0ac8eb6df50d1aba (diff) | |
download | vt100-rust-267f7452949617375c8570caf4b03b434e3350e8.tar.gz vt100-rust-267f7452949617375c8570caf4b03b434e3350e8.zip |
basic structure of vte parser
Diffstat (limited to 'tests/processing.rs')
-rw-r--r-- | tests/processing.rs | 196 |
1 files changed, 147 insertions, 49 deletions
diff --git a/tests/processing.rs b/tests/processing.rs index 3110814..0e801d2 100644 --- a/tests/processing.rs +++ b/tests/processing.rs @@ -3,64 +3,162 @@ #[test] fn split_escape_sequences() { let mut screen = vt100::Screen::new(24, 80); - assert_eq!(screen.process(b"abc"), 3); - assert_eq!(screen.process(b"abc\x1b[12;24Hdef"), 14); + let contents = screen.window_contents(0, 0, 23, 79); + screen.process(b"abc"); + assert_ne!(screen.window_contents(0, 0, 23, 79), contents); + let contents = screen.window_contents(0, 0, 23, 79); + screen.process(b"abc\x1b[12;24Hdef"); + assert_ne!(screen.window_contents(0, 0, 23, 79), contents); + let contents = screen.window_contents(0, 0, 23, 79); + assert!(contents.contains("abc")); + assert!(contents.contains("def")); + assert_eq!(screen.cursor_position(), (11, 26)); - assert_eq!(screen.process(b"\x1b"), 0); - assert_eq!(screen.process(b"\x1b["), 0); - assert_eq!(screen.process(b"\x1b[1"), 0); - assert_eq!(screen.process(b"\x1b[12"), 0); - assert_eq!(screen.process(b"\x1b[12;"), 0); - assert_eq!(screen.process(b"\x1b[12;2"), 0); - assert_eq!(screen.process(b"\x1b[12;24"), 0); - assert_eq!(screen.process(b"\x1b[12;24H"), 8); + screen.process(b"\x1b"); + assert_eq!(screen.cursor_position(), (11, 26)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"["); + assert_eq!(screen.cursor_position(), (11, 26)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"1"); + assert_eq!(screen.cursor_position(), (11, 26)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"2"); + assert_eq!(screen.cursor_position(), (11, 26)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b";"); + assert_eq!(screen.cursor_position(), (11, 26)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"2"); + assert_eq!(screen.cursor_position(), (11, 26)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"4"); + assert_eq!(screen.cursor_position(), (11, 26)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"H"); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); - assert_eq!(screen.process(b"abc\x1b"), 3); - assert_eq!(screen.process(b"abc\x1b["), 3); - assert_eq!(screen.process(b"abc\x1b[1"), 3); - assert_eq!(screen.process(b"abc\x1b[12"), 3); - assert_eq!(screen.process(b"abc\x1b[12;"), 3); - assert_eq!(screen.process(b"abc\x1b[12;2"), 3); - assert_eq!(screen.process(b"abc\x1b[12;24"), 3); - assert_eq!(screen.process(b"abc\x1b[12;24H"), 11); + assert!(!screen.mouse_reporting_press_release()); + screen.process(b"\x1b"); + assert!(!screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"["); + assert!(!screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"?"); + assert!(!screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"1"); + assert!(!screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"0"); + assert!(!screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"0"); + assert!(!screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"0"); + assert!(!screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"h"); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); - assert_eq!(screen.process(b"\x1b"), 0); - assert_eq!(screen.process(b"\x1b["), 0); - assert_eq!(screen.process(b"\x1b[?"), 0); - assert_eq!(screen.process(b"\x1b[?1"), 0); - assert_eq!(screen.process(b"\x1b[?10"), 0); - assert_eq!(screen.process(b"\x1b[?100"), 0); - assert_eq!(screen.process(b"\x1b[?1000"), 0); - assert_eq!(screen.process(b"\x1b[?1000h"), 8); - - assert_eq!(screen.process(b"\x1b]"), 0); - assert_eq!(screen.process(b"\x1b]4"), 0); - assert_eq!(screen.process(b"\x1b]49"), 0); - assert_eq!(screen.process(b"\x1b]499"), 0); - assert_eq!(screen.process(b"\x1b]499;"), 0); - assert_eq!(screen.process(b"\x1b]499;a"), 0); - assert_eq!(screen.process(b"\x1b]499;a "), 0); - assert_eq!(screen.process(b"\x1b]499;a '"), 0); - assert_eq!(screen.process(b"\x1b]499;a '["), 0); - assert_eq!(screen.process(b"\x1b]499;a '[]"), 0); - assert_eq!(screen.process(b"\x1b]499;a '[]_"), 0); - assert_eq!(screen.process(b"\x1b]499;a '[]_\x07"), 13); + assert_eq!(screen.title(), None); + screen.process(b"\x1b"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"]"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"0"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b";"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"a"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b" "); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"'"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"["); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"]"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"_"); + assert_eq!(screen.title(), None); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"\x07"); + assert_eq!(screen.title(), Some("a '[]_")); + assert!(screen.mouse_reporting_press_release()); + assert_eq!(screen.cursor_position(), (11, 23)); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); } #[test] fn split_utf8() { let mut screen = vt100::Screen::new(24, 80); - assert_eq!(screen.process(b"a"), 1); + let contents = screen.window_contents(0, 0, 23, 79); + screen.process(b"a"); + assert_ne!(screen.window_contents(0, 0, 23, 79), contents); + let contents = screen.window_contents(0, 0, 23, 79); - assert_eq!(screen.process(b"\xc3"), 0); - assert_eq!(screen.process(b"\xc3\xa1"), 2); + screen.process(b"\xc3"); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"\xa1"); + assert_ne!(screen.window_contents(0, 0, 23, 79), contents); + let contents = screen.window_contents(0, 0, 23, 79); - assert_eq!(screen.process(b"\xe3"), 0); - assert_eq!(screen.process(b"\xe3\x82"), 0); - assert_eq!(screen.process(b"\xe3\x82\xad"), 3); + screen.process(b"\xe3"); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"\x82"); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"\xad"); + assert_ne!(screen.window_contents(0, 0, 23, 79), contents); + let contents = screen.window_contents(0, 0, 23, 79); - assert_eq!(screen.process(b"\xf0"), 0); - assert_eq!(screen.process(b"\xf0\x9f"), 0); - assert_eq!(screen.process(b"\xf0\x9f\x92"), 0); - assert_eq!(screen.process(b"\xf0\x9f\x92\xa9"), 4); + screen.process(b"\xf0"); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"\x9f"); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"\x92"); + assert_eq!(screen.window_contents(0, 0, 23, 79), contents); + screen.process(b"\xa9"); + assert_ne!(screen.window_contents(0, 0, 23, 79), contents); } |