aboutsummaryrefslogtreecommitdiffstats
path: root/tests/text.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-10-29 14:24:28 -0400
committerJesse Luehrs <doy@tozt.net>2019-10-29 14:24:28 -0400
commit267f7452949617375c8570caf4b03b434e3350e8 (patch)
tree517ba3be3617c8ca60e804b1e033388e069c37b0 /tests/text.rs
parentf84638fd816d2295c5d9f60c0ac8eb6df50d1aba (diff)
downloadvt100-rust-267f7452949617375c8570caf4b03b434e3350e8.tar.gz
vt100-rust-267f7452949617375c8570caf4b03b434e3350e8.zip
basic structure of vte parser
Diffstat (limited to 'tests/text.rs')
-rw-r--r--tests/text.rs55
1 files changed, 26 insertions, 29 deletions
diff --git a/tests/text.rs b/tests/text.rs
index 140b32f..4ece65b 100644
--- a/tests/text.rs
+++ b/tests/text.rs
@@ -1,12 +1,9 @@
#![allow(clippy::cognitive_complexity)]
-mod support;
-use support::TestHelpers;
-
#[test]
fn ascii() {
let mut screen = vt100::Screen::new(24, 80);
- screen.assert_process(b"foo");
+ screen.process(b"foo");
assert_eq!(screen.cell(0, 0).unwrap().contents(), "f");
assert_eq!(screen.cell(0, 1).unwrap().contents(), "o");
assert_eq!(screen.cell(0, 2).unwrap().contents(), "o");
@@ -25,7 +22,7 @@ fn ascii() {
#[test]
fn utf8() {
let mut screen = vt100::Screen::new(24, 80);
- screen.assert_process("café".as_bytes());
+ screen.process("café".as_bytes());
assert_eq!(screen.cell(0, 0).unwrap().contents(), "c");
assert_eq!(screen.cell(0, 1).unwrap().contents(), "a");
assert_eq!(screen.cell(0, 2).unwrap().contents(), "f");
@@ -45,7 +42,7 @@ fn utf8() {
#[test]
fn newlines() {
let mut screen = vt100::Screen::new(24, 80);
- screen.assert_process(b"f\r\noo\r\nood");
+ screen.process(b"f\r\noo\r\nood");
assert_eq!(screen.cell(0, 0).unwrap().contents(), "f");
assert_eq!(screen.cell(0, 1).unwrap().contents(), "");
assert_eq!(screen.cell(0, 2).unwrap().contents(), "");
@@ -70,7 +67,7 @@ fn newlines() {
#[test]
fn wide() {
let mut screen = vt100::Screen::new(24, 80);
- screen.assert_process("aデbネ".as_bytes());
+ screen.process("aデbネ".as_bytes());
assert_eq!(screen.cell(0, 0).unwrap().contents(), "a");
assert_eq!(screen.cell(0, 1).unwrap().contents(), "デ");
assert_eq!(screen.cell(0, 2).unwrap().contents(), "");
@@ -92,17 +89,17 @@ fn wide() {
#[test]
fn combining() {
let mut screen = vt100::Screen::new(24, 80);
- screen.assert_process(b"a");
+ screen.process(b"a");
assert_eq!(screen.cell(0, 0).unwrap().contents(), "a");
- screen.assert_process("\u{0301}".as_bytes());
+ screen.process("\u{0301}".as_bytes());
assert_eq!(screen.cell(0, 0).unwrap().contents(), "á");
- screen.assert_process(b"\x1b[20;20Habcdefg");
+ screen.process(b"\x1b[20;20Habcdefg");
assert_eq!(screen.window_contents(19, 19, 19, 26), "abcdefg");
- screen.assert_process("\x1b[20;25H\u{0301}".as_bytes());
+ screen.process("\x1b[20;25H\u{0301}".as_bytes());
assert_eq!(screen.window_contents(19, 19, 19, 26), "abcdéfg");
- screen.assert_process(b"\x1b[10;78Haaa");
+ screen.process(b"\x1b[10;78Haaa");
assert_eq!(screen.cell(9, 79).unwrap().contents(), "a");
- screen.assert_process("\r\n\u{0301}".as_bytes());
+ screen.process("\r\n\u{0301}".as_bytes());
assert_eq!(screen.cell(9, 79).unwrap().contents(), "a");
assert_eq!(screen.cell(10, 0).unwrap().contents(), "");
}
@@ -110,34 +107,34 @@ fn combining() {
#[test]
fn wrap() {
let mut screen = vt100::Screen::new(24, 80);
- screen.assert_process(b"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
+ screen.process(b"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
assert_eq!(screen.window_contents(0, 0, 23, 79), "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- screen.assert_process(b"\x1b[5H01234567890123456789012345678901234567890123456789012345678901234567890123456789");
- screen.assert_process(b"\x1b[6H01234567890123456789012345678901234567890123456789012345678901234567890123456789");
+ screen.process(b"\x1b[5H01234567890123456789012345678901234567890123456789012345678901234567890123456789");
+ screen.process(b"\x1b[6H01234567890123456789012345678901234567890123456789012345678901234567890123456789");
assert_eq!(screen.window_contents(0, 0, 23, 79), "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n\n\n01234567890123456789012345678901234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789012345678901234567890123456789\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- screen.assert_process(b"\x1b[H\x1b[J");
- screen.assert_process(b"0123456789012345678901234567890123456789012345678901234567890123456789012345678");
+ screen.process(b"\x1b[H\x1b[J");
+ screen.process(b"0123456789012345678901234567890123456789012345678901234567890123456789012345678");
assert_eq!(screen.window_contents(0, 0, 23, 79), "0123456789012345678901234567890123456789012345678901234567890123456789012345678\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, 79));
- screen.assert_process(b"9");
+ screen.process(b"9");
assert_eq!(screen.window_contents(0, 0, 23, 79), "01234567890123456789012345678901234567890123456789012345678901234567890123456789\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, 80));
- screen.assert_process(b"a");
+ screen.process(b"a");
assert_eq!(screen.window_contents(0, 0, 23, 79), "01234567890123456789012345678901234567890123456789012345678901234567890123456789a\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(), (1, 1));
- screen.assert_process(b"b");
+ screen.process(b"b");
assert_eq!(screen.window_contents(0, 0, 23, 79), "01234567890123456789012345678901234567890123456789012345678901234567890123456789ab\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(), (1, 2));
- screen.assert_process(b"\x1b[H\x1b[J");
- screen.assert_process(b"012345678901234567890123456789012345678901234567890123456789012345678901234567");
+ screen.process(b"\x1b[H\x1b[J");
+ screen.process(b"012345678901234567890123456789012345678901234567890123456789012345678901234567");
assert_eq!(screen.window_contents(0, 0, 23, 79), "012345678901234567890123456789012345678901234567890123456789012345678901234567\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, 78));
- screen.assert_process("ネ".as_bytes());
+ screen.process("ネ".as_bytes());
assert_eq!(screen.window_contents(0, 0, 23, 79), "012345678901234567890123456789012345678901234567890123456789012345678901234567ネ\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, 80));
- screen.assert_process(b"a");
+ screen.process(b"a");
assert_eq!(screen.window_contents(0, 0, 23, 79), "012345678901234567890123456789012345678901234567890123456789012345678901234567ネa\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(), (1, 1));
assert_eq!(screen.cell(0, 77).unwrap().contents(), "7");
@@ -146,14 +143,14 @@ fn wrap() {
assert_eq!(screen.cell(1, 0).unwrap().contents(), "a");
assert_eq!(screen.cell(1, 1).unwrap().contents(), "");
- screen.assert_process(b"\x1b[H\x1b[J");
- screen.assert_process(b"0123456789012345678901234567890123456789012345678901234567890123456789012345678");
+ screen.process(b"\x1b[H\x1b[J");
+ screen.process(b"0123456789012345678901234567890123456789012345678901234567890123456789012345678");
assert_eq!(screen.window_contents(0, 0, 23, 79), "0123456789012345678901234567890123456789012345678901234567890123456789012345678\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, 79));
- screen.assert_process("ネ".as_bytes());
+ screen.process("ネ".as_bytes());
assert_eq!(screen.window_contents(0, 0, 23, 79), "0123456789012345678901234567890123456789012345678901234567890123456789012345678ネ\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(), (1, 2));
- screen.assert_process(b"a");
+ screen.process(b"a");
assert_eq!(screen.window_contents(0, 0, 23, 79), "0123456789012345678901234567890123456789012345678901234567890123456789012345678ネa\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(), (1, 3));
assert_eq!(screen.cell(0, 77).unwrap().contents(), "7");