aboutsummaryrefslogtreecommitdiffstats
path: root/tests/control.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-05 01:32:25 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-05 01:32:25 -0500
commit4b4a9c18e4c55a2ba6558ef614292db9c18ab88a (patch)
tree03c9ada690835acbf3d1b02f46341bde5b579989 /tests/control.rs
parent59e7c620a516278719c1689ebebeb558bede5b60 (diff)
downloadvt100-rust-4b4a9c18e4c55a2ba6558ef614292db9c18ab88a.tar.gz
vt100-rust-4b4a9c18e4c55a2ba6558ef614292db9c18ab88a.zip
expose the screen separately from the parser
Diffstat (limited to 'tests/control.rs')
-rw-r--r--tests/control.rs122
1 files changed, 61 insertions, 61 deletions
diff --git a/tests/control.rs b/tests/control.rs
index b1e8ea2..03352b7 100644
--- a/tests/control.rs
+++ b/tests/control.rs
@@ -1,74 +1,74 @@
#[test]
fn bel() {
- let mut screen = vt100::Screen::new(24, 80);
+ let mut parser = vt100::Parser::new(24, 80);
- assert!(!screen.check_audible_bell());
+ assert!(!parser.screen_mut().check_audible_bell());
- screen.process(b"\x07");
- assert!(screen.check_audible_bell());
- assert!(!screen.check_audible_bell());
+ parser.process(b"\x07");
+ assert!(parser.screen_mut().check_audible_bell());
+ assert!(!parser.screen_mut().check_audible_bell());
}
#[test]
fn bs() {
- let mut screen = vt100::Screen::new(24, 80);
+ let mut parser = vt100::Parser::new(24, 80);
- screen.process(b"foo\x08\x08aa");
- assert_eq!(screen.cell(0, 0).unwrap().contents(), "f");
- assert_eq!(screen.cell(0, 1).unwrap().contents(), "a");
- assert_eq!(screen.cell(0, 2).unwrap().contents(), "a");
- assert_eq!(screen.cell(0, 3).unwrap().contents(), "");
- assert_eq!(screen.cell(1, 0).unwrap().contents(), "");
- assert_eq!(screen.contents(0, 0, 23, 79), "faa");
+ parser.process(b"foo\x08\x08aa");
+ assert_eq!(parser.screen().cell(0, 0).unwrap().contents(), "f");
+ assert_eq!(parser.screen().cell(0, 1).unwrap().contents(), "a");
+ assert_eq!(parser.screen().cell(0, 2).unwrap().contents(), "a");
+ assert_eq!(parser.screen().cell(0, 3).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(1, 0).unwrap().contents(), "");
+ assert_eq!(parser.screen().contents(0, 0, 23, 79), "faa");
- screen.process(b"\r\nquux\x08\x08\x08\x08\x08\x08bar");
- assert_eq!(screen.cell(1, 0).unwrap().contents(), "b");
- assert_eq!(screen.cell(1, 1).unwrap().contents(), "a");
- assert_eq!(screen.cell(1, 2).unwrap().contents(), "r");
- assert_eq!(screen.cell(1, 3).unwrap().contents(), "x");
- assert_eq!(screen.cell(1, 4).unwrap().contents(), "");
- assert_eq!(screen.cell(2, 0).unwrap().contents(), "");
- assert_eq!(screen.contents(0, 0, 23, 79), "faa\nbarx");
+ parser.process(b"\r\nquux\x08\x08\x08\x08\x08\x08bar");
+ assert_eq!(parser.screen().cell(1, 0).unwrap().contents(), "b");
+ assert_eq!(parser.screen().cell(1, 1).unwrap().contents(), "a");
+ assert_eq!(parser.screen().cell(1, 2).unwrap().contents(), "r");
+ assert_eq!(parser.screen().cell(1, 3).unwrap().contents(), "x");
+ assert_eq!(parser.screen().cell(1, 4).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(2, 0).unwrap().contents(), "");
+ assert_eq!(parser.screen().contents(0, 0, 23, 79), "faa\nbarx");
}
#[test]
fn tab() {
- let mut screen = vt100::Screen::new(24, 80);
+ let mut parser = vt100::Parser::new(24, 80);
- screen.process(b"foo\tbar");
- 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");
- assert_eq!(screen.cell(0, 3).unwrap().contents(), "");
- assert_eq!(screen.cell(0, 4).unwrap().contents(), "");
- assert_eq!(screen.cell(0, 5).unwrap().contents(), "");
- assert_eq!(screen.cell(0, 6).unwrap().contents(), "");
- assert_eq!(screen.cell(0, 7).unwrap().contents(), "");
- assert_eq!(screen.cell(0, 8).unwrap().contents(), "b");
- assert_eq!(screen.cell(0, 9).unwrap().contents(), "a");
- assert_eq!(screen.cell(0, 10).unwrap().contents(), "r");
- assert_eq!(screen.cell(0, 11).unwrap().contents(), "");
- assert_eq!(screen.contents(0, 0, 23, 79), "foo bar");
+ parser.process(b"foo\tbar");
+ assert_eq!(parser.screen().cell(0, 0).unwrap().contents(), "f");
+ assert_eq!(parser.screen().cell(0, 1).unwrap().contents(), "o");
+ assert_eq!(parser.screen().cell(0, 2).unwrap().contents(), "o");
+ assert_eq!(parser.screen().cell(0, 3).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(0, 4).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(0, 5).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(0, 6).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(0, 7).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(0, 8).unwrap().contents(), "b");
+ assert_eq!(parser.screen().cell(0, 9).unwrap().contents(), "a");
+ assert_eq!(parser.screen().cell(0, 10).unwrap().contents(), "r");
+ assert_eq!(parser.screen().cell(0, 11).unwrap().contents(), "");
+ assert_eq!(parser.screen().contents(0, 0, 23, 79), "foo bar");
}
fn lf_with(b: u8) {
- let mut screen = vt100::Screen::new(24, 80);
+ let mut parser = vt100::Parser::new(24, 80);
- screen.process(b"foo");
- screen.process(&[b]);
- screen.process(b"bar");
- 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");
- assert_eq!(screen.cell(0, 3).unwrap().contents(), "");
- assert_eq!(screen.cell(1, 0).unwrap().contents(), "");
- assert_eq!(screen.cell(1, 1).unwrap().contents(), "");
- assert_eq!(screen.cell(1, 2).unwrap().contents(), "");
- assert_eq!(screen.cell(1, 3).unwrap().contents(), "b");
- assert_eq!(screen.cell(1, 4).unwrap().contents(), "a");
- assert_eq!(screen.cell(1, 5).unwrap().contents(), "r");
- assert_eq!(screen.cell(1, 6).unwrap().contents(), "");
- assert_eq!(screen.contents(0, 0, 23, 79), "foo\n bar");
+ parser.process(b"foo");
+ parser.process(&[b]);
+ parser.process(b"bar");
+ assert_eq!(parser.screen().cell(0, 0).unwrap().contents(), "f");
+ assert_eq!(parser.screen().cell(0, 1).unwrap().contents(), "o");
+ assert_eq!(parser.screen().cell(0, 2).unwrap().contents(), "o");
+ assert_eq!(parser.screen().cell(0, 3).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(1, 0).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(1, 1).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(1, 2).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(1, 3).unwrap().contents(), "b");
+ assert_eq!(parser.screen().cell(1, 4).unwrap().contents(), "a");
+ assert_eq!(parser.screen().cell(1, 5).unwrap().contents(), "r");
+ assert_eq!(parser.screen().cell(1, 6).unwrap().contents(), "");
+ assert_eq!(parser.screen().contents(0, 0, 23, 79), "foo\n bar");
}
#[test]
@@ -88,14 +88,14 @@ fn ff() {
#[test]
fn cr() {
- let mut screen = vt100::Screen::new(24, 80);
+ let mut parser = vt100::Parser::new(24, 80);
- screen.process(b"fooo\rbar");
- assert_eq!(screen.cell(0, 0).unwrap().contents(), "b");
- assert_eq!(screen.cell(0, 1).unwrap().contents(), "a");
- assert_eq!(screen.cell(0, 2).unwrap().contents(), "r");
- assert_eq!(screen.cell(0, 3).unwrap().contents(), "o");
- assert_eq!(screen.cell(0, 4).unwrap().contents(), "");
- assert_eq!(screen.cell(1, 0).unwrap().contents(), "");
- assert_eq!(screen.contents(0, 0, 23, 79), "baro");
+ parser.process(b"fooo\rbar");
+ assert_eq!(parser.screen().cell(0, 0).unwrap().contents(), "b");
+ assert_eq!(parser.screen().cell(0, 1).unwrap().contents(), "a");
+ assert_eq!(parser.screen().cell(0, 2).unwrap().contents(), "r");
+ assert_eq!(parser.screen().cell(0, 3).unwrap().contents(), "o");
+ assert_eq!(parser.screen().cell(0, 4).unwrap().contents(), "");
+ assert_eq!(parser.screen().cell(1, 0).unwrap().contents(), "");
+ assert_eq!(parser.screen().contents(0, 0, 23, 79), "baro");
}