diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-29 12:40:41 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-29 12:40:41 -0400 |
commit | e525fddb572614f4c6d6a7d71ed44e9dfe7af350 (patch) | |
tree | 673d83f4e040080fd9040ea4d711546d18dd1bd6 /tests | |
parent | 0cd015222e80497c823fc0eadc8f55c45860bade (diff) | |
download | vt100-rust-e525fddb572614f4c6d6a7d71ed44e9dfe7af350.tar.gz vt100-rust-e525fddb572614f4c6d6a7d71ed44e9dfe7af350.zip |
rustfmt
Diffstat (limited to 'tests')
-rw-r--r-- | tests/attr.rs | 180 | ||||
-rw-r--r-- | tests/control.rs | 25 | ||||
-rw-r--r-- | tests/csi.rs | 167 | ||||
-rw-r--r-- | tests/escape.rs | 35 | ||||
-rw-r--r-- | tests/init.rs | 10 | ||||
-rw-r--r-- | tests/mode.rs | 10 | ||||
-rw-r--r-- | tests/text.rs | 40 |
7 files changed, 354 insertions, 113 deletions
diff --git a/tests/attr.rs b/tests/attr.rs index 33582c5..2532819 100644 --- a/tests/attr.rs +++ b/tests/attr.rs @@ -12,12 +12,24 @@ fn colors() { screen.assert_process(b"foo\x1b[31mbar"); assert_eq!(screen.cell(0, 0).unwrap().contents(), "f"); - assert_eq!(screen.cell(0, 0).unwrap().fgcolor(), vt100::Color::ColorDefault); - assert_eq!(screen.cell(0, 0).unwrap().bgcolor(), vt100::Color::ColorDefault); + assert_eq!( + screen.cell(0, 0).unwrap().fgcolor(), + vt100::Color::ColorDefault + ); + assert_eq!( + screen.cell(0, 0).unwrap().bgcolor(), + vt100::Color::ColorDefault + ); assert_eq!(screen.cell(0, 3).unwrap().contents(), "b"); - assert_eq!(screen.cell(0, 3).unwrap().fgcolor(), vt100::Color::ColorIdx(1)); - assert_eq!(screen.cell(0, 3).unwrap().bgcolor(), vt100::Color::ColorDefault); + assert_eq!( + screen.cell(0, 3).unwrap().fgcolor(), + vt100::Color::ColorIdx(1) + ); + assert_eq!( + screen.cell(0, 3).unwrap().bgcolor(), + vt100::Color::ColorDefault + ); assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(1)); assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault); @@ -25,8 +37,14 @@ fn colors() { screen.assert_process(b"\x1b[2D\x1b[45mab"); assert_eq!(screen.cell(0, 4).unwrap().contents(), "a"); - assert_eq!(screen.cell(0, 4).unwrap().fgcolor(), vt100::Color::ColorIdx(1)); - assert_eq!(screen.cell(0, 4).unwrap().bgcolor(), vt100::Color::ColorIdx(5)); + assert_eq!( + screen.cell(0, 4).unwrap().fgcolor(), + vt100::Color::ColorIdx(1) + ); + assert_eq!( + screen.cell(0, 4).unwrap().bgcolor(), + vt100::Color::ColorIdx(5) + ); assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(1)); assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(5)); @@ -39,12 +57,24 @@ fn colors() { screen.assert_process(b"\x1b[15;15Hfoo\x1b[31mbar\x1b[m"); assert_eq!(screen.cell(14, 14).unwrap().contents(), "f"); - assert_eq!(screen.cell(14, 14).unwrap().fgcolor(), vt100::Color::ColorDefault); - assert_eq!(screen.cell(14, 14).unwrap().bgcolor(), vt100::Color::ColorDefault); + assert_eq!( + screen.cell(14, 14).unwrap().fgcolor(), + vt100::Color::ColorDefault + ); + assert_eq!( + screen.cell(14, 14).unwrap().bgcolor(), + vt100::Color::ColorDefault + ); assert_eq!(screen.cell(14, 17).unwrap().contents(), "b"); - assert_eq!(screen.cell(14, 17).unwrap().fgcolor(), vt100::Color::ColorIdx(1)); - assert_eq!(screen.cell(14, 17).unwrap().bgcolor(), vt100::Color::ColorDefault); + assert_eq!( + screen.cell(14, 17).unwrap().fgcolor(), + vt100::Color::ColorIdx(1) + ); + assert_eq!( + screen.cell(14, 17).unwrap().bgcolor(), + vt100::Color::ColorDefault + ); assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault); assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault); @@ -52,8 +82,14 @@ fn colors() { screen.assert_process(b"\x1b[2D\x1b[45mab"); assert_eq!(screen.cell(14, 18).unwrap().contents(), "a"); - assert_eq!(screen.cell(14, 18).unwrap().fgcolor(), vt100::Color::ColorDefault); - assert_eq!(screen.cell(14, 18).unwrap().bgcolor(), vt100::Color::ColorIdx(5)); + assert_eq!( + screen.cell(14, 18).unwrap().fgcolor(), + vt100::Color::ColorDefault + ); + assert_eq!( + screen.cell(14, 18).unwrap().bgcolor(), + vt100::Color::ColorIdx(5) + ); assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault); assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(5)); @@ -64,25 +100,55 @@ fn colors() { assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(123)); assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(158)); - assert_eq!(screen.cell(0, 0).unwrap().fgcolor(), vt100::Color::ColorDefault); - assert_eq!(screen.cell(0, 0).unwrap().bgcolor(), vt100::Color::ColorDefault); - - assert_eq!(screen.cell(0, 1).unwrap().fgcolor(), vt100::Color::ColorIdx(123)); - assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::ColorDefault); - - assert_eq!(screen.cell(0, 2).unwrap().fgcolor(), vt100::Color::ColorIdx(123)); - assert_eq!(screen.cell(0, 2).unwrap().bgcolor(), vt100::Color::ColorIdx(158)); + assert_eq!( + screen.cell(0, 0).unwrap().fgcolor(), + vt100::Color::ColorDefault + ); + assert_eq!( + screen.cell(0, 0).unwrap().bgcolor(), + vt100::Color::ColorDefault + ); + + assert_eq!( + screen.cell(0, 1).unwrap().fgcolor(), + vt100::Color::ColorIdx(123) + ); + assert_eq!( + screen.cell(0, 1).unwrap().bgcolor(), + vt100::Color::ColorDefault + ); + + assert_eq!( + screen.cell(0, 2).unwrap().fgcolor(), + vt100::Color::ColorIdx(123) + ); + assert_eq!( + screen.cell(0, 2).unwrap().bgcolor(), + vt100::Color::ColorIdx(158) + ); screen.assert_process(b"\x1b[38;2;50;75;100md\x1b[48;2;125;150;175me"); assert_eq!(screen.fgcolor(), vt100::Color::ColorRgb(50, 75, 100)); assert_eq!(screen.bgcolor(), vt100::Color::ColorRgb(125, 150, 175)); - assert_eq!(screen.cell(0, 3).unwrap().fgcolor(), vt100::Color::ColorRgb(50, 75, 100)); - assert_eq!(screen.cell(0, 3).unwrap().bgcolor(), vt100::Color::ColorIdx(158)); - - assert_eq!(screen.cell(0, 4).unwrap().fgcolor(), vt100::Color::ColorRgb(50, 75, 100)); - assert_eq!(screen.cell(0, 4).unwrap().bgcolor(), vt100::Color::ColorRgb(125, 150, 175)); + assert_eq!( + screen.cell(0, 3).unwrap().fgcolor(), + vt100::Color::ColorRgb(50, 75, 100) + ); + assert_eq!( + screen.cell(0, 3).unwrap().bgcolor(), + vt100::Color::ColorIdx(158) + ); + + assert_eq!( + screen.cell(0, 4).unwrap().fgcolor(), + vt100::Color::ColorRgb(50, 75, 100) + ); + assert_eq!( + screen.cell(0, 4).unwrap().bgcolor(), + vt100::Color::ColorRgb(125, 150, 175) + ); screen.assert_process(b"\x1b[m\x1b[2J\x1b[H"); screen.assert_process(b"\x1b[32;47mfoo"); @@ -90,8 +156,14 @@ fn colors() { assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(2)); assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(7)); - assert_eq!(screen.cell(0, 1).unwrap().fgcolor(), vt100::Color::ColorIdx(2)); - assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::ColorIdx(7)); + assert_eq!( + screen.cell(0, 1).unwrap().fgcolor(), + vt100::Color::ColorIdx(2) + ); + assert_eq!( + screen.cell(0, 1).unwrap().bgcolor(), + vt100::Color::ColorIdx(7) + ); } #[test] @@ -103,30 +175,30 @@ fn attrs() { assert!(!screen.inverse()); screen.assert_process(b"f\x1b[1mo\x1b[3mo\x1b[4mo\x1b[7mo"); - assert!( screen.bold()); - assert!( screen.italic()); - assert!( screen.underline()); - assert!( screen.inverse()); + assert!(screen.bold()); + assert!(screen.italic()); + assert!(screen.underline()); + assert!(screen.inverse()); assert!(!screen.cell(0, 0).unwrap().bold()); assert!(!screen.cell(0, 0).unwrap().italic()); assert!(!screen.cell(0, 0).unwrap().underline()); assert!(!screen.cell(0, 0).unwrap().inverse()); - assert!( screen.cell(0, 1).unwrap().bold()); + assert!(screen.cell(0, 1).unwrap().bold()); assert!(!screen.cell(0, 1).unwrap().italic()); assert!(!screen.cell(0, 1).unwrap().underline()); assert!(!screen.cell(0, 1).unwrap().inverse()); - assert!( screen.cell(0, 2).unwrap().bold()); - assert!( screen.cell(0, 2).unwrap().italic()); + assert!(screen.cell(0, 2).unwrap().bold()); + assert!(screen.cell(0, 2).unwrap().italic()); assert!(!screen.cell(0, 2).unwrap().underline()); assert!(!screen.cell(0, 2).unwrap().inverse()); - assert!( screen.cell(0, 3).unwrap().bold()); - assert!( screen.cell(0, 3).unwrap().italic()); - assert!( screen.cell(0, 3).unwrap().underline()); + assert!(screen.cell(0, 3).unwrap().bold()); + assert!(screen.cell(0, 3).unwrap().italic()); + assert!(screen.cell(0, 3).unwrap().underline()); assert!(!screen.cell(0, 3).unwrap().inverse()); - assert!( screen.cell(0, 4).unwrap().bold()); - assert!( screen.cell(0, 4).unwrap().italic()); - assert!( screen.cell(0, 4).unwrap().underline()); - assert!( screen.cell(0, 4).unwrap().inverse()); + assert!(screen.cell(0, 4).unwrap().bold()); + assert!(screen.cell(0, 4).unwrap().italic()); + assert!(screen.cell(0, 4).unwrap().underline()); + assert!(screen.cell(0, 4).unwrap().inverse()); screen.assert_process(b"\x1b[m"); assert!(!screen.bold()); @@ -136,13 +208,13 @@ fn attrs() { screen.assert_process(b"\x1b[2J\x1b[H"); screen.assert_process(b"\x1b[1;4mf"); - assert!( screen.bold()); + assert!(screen.bold()); assert!(!screen.italic()); - assert!( screen.underline()); + assert!(screen.underline()); assert!(!screen.inverse()); - assert!( screen.cell(0, 0).unwrap().bold()); + assert!(screen.cell(0, 0).unwrap().bold()); assert!(!screen.cell(0, 0).unwrap().italic()); - assert!( screen.cell(0, 0).unwrap().underline()); + assert!(screen.cell(0, 0).unwrap().underline()); assert!(!screen.cell(0, 0).unwrap().inverse()); screen.assert_process(b"\x1b[22mo\x1b[24mo"); @@ -152,7 +224,7 @@ fn attrs() { assert!(!screen.inverse()); assert!(!screen.cell(0, 1).unwrap().bold()); assert!(!screen.cell(0, 1).unwrap().italic()); - assert!( screen.cell(0, 1).unwrap().underline()); + assert!(screen.cell(0, 1).unwrap().underline()); assert!(!screen.cell(0, 1).unwrap().inverse()); assert!(!screen.cell(0, 2).unwrap().bold()); assert!(!screen.cell(0, 2).unwrap().italic()); @@ -160,12 +232,12 @@ fn attrs() { assert!(!screen.cell(0, 2).unwrap().inverse()); screen.assert_process(b"\x1b[1;3;4;7mo"); - assert!( screen.bold()); - assert!( screen.italic()); - assert!( screen.underline()); - assert!( screen.inverse()); - assert!( screen.cell(0, 3).unwrap().bold()); - assert!( screen.cell(0, 3).unwrap().italic()); - assert!( screen.cell(0, 3).unwrap().underline()); - assert!( screen.cell(0, 3).unwrap().inverse()); + assert!(screen.bold()); + assert!(screen.italic()); + assert!(screen.underline()); + assert!(screen.inverse()); + assert!(screen.cell(0, 3).unwrap().bold()); + assert!(screen.cell(0, 3).unwrap().italic()); + assert!(screen.cell(0, 3).unwrap().underline()); + assert!(screen.cell(0, 3).unwrap().inverse()); } diff --git a/tests/control.rs b/tests/control.rs index 837f83c..787bdc2 100644 --- a/tests/control.rs +++ b/tests/control.rs @@ -24,7 +24,10 @@ fn bs() { 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.window_contents(0, 0, 23, 79), "faa\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.window_contents(0, 0, 23, 79), + "faa\n\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"\r\nquux\x08\x08\x08\x08\x08\x08bar"); assert_eq!(screen.cell(1, 0).unwrap().contents(), "b"); @@ -33,7 +36,10 @@ fn bs() { 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.window_contents(0, 0, 23, 79), "faa\nbarx\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.window_contents(0, 0, 23, 79), + "faa\nbarx\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] @@ -53,7 +59,10 @@ fn tab() { 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.window_contents(0, 0, 23, 79), "foo bar\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.window_contents(0, 0, 23, 79), + "foo bar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] @@ -72,7 +81,10 @@ fn lf() { 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.window_contents(0, 0, 23, 79), "foo\n bar\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.window_contents(0, 0, 23, 79), + "foo\n bar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] @@ -86,5 +98,8 @@ fn cr() { 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.window_contents(0, 0, 23, 79), "baro\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.window_contents(0, 0, 23, 79), + "baro\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } diff --git a/tests/csi.rs b/tests/csi.rs index d525262..e19f377 100644 --- a/tests/csi.rs +++ b/tests/csi.rs @@ -96,7 +96,10 @@ fn relative_movement() { #[test] fn ed() { let mut screen = vt100::Screen::new(24, 80); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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"foo\x1b[5;5Hbar\x1b[10;10Hbaz\x1b[20;20Hquux"); assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n bar\n\n\n\n\n baz\n\n\n\n\n\n\n\n\n\n quux\n\n\n\n\n"); @@ -105,13 +108,22 @@ fn ed() { assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n bar\n\n\n\n\n ba\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); screen.assert_process(b"\x1b[5;7H\x1b[1J"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n r\n\n\n\n\n ba\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n r\n\n\n\n\n ba\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); screen.assert_process(b"\x1b[7;7H\x1b[2J"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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[2J\x1b[H"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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"foo\x1b[5;5Hbar\x1b[10;10Hbaz\x1b[20;20Hquux"); assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n bar\n\n\n\n\n baz\n\n\n\n\n\n\n\n\n\n quux\n\n\n\n\n"); @@ -120,7 +132,10 @@ fn ed() { assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n bar\n\n\n\n\n ba\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); screen.assert_process(b"\x1b[2J\x1b[H"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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"foo\x1b[5;5Hbar\x1b[10;10Hbaz\x1b[20;20Hquux"); assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n bar\n\n\n\n\n baz\n\n\n\n\n\n\n\n\n\n quux\n\n\n\n\n"); @@ -129,13 +144,22 @@ fn ed() { assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n bar\n\n\n\n\n ba\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); screen.assert_process(b"\x1b[5;7H\x1b[?1J"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n r\n\n\n\n\n ba\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n r\n\n\n\n\n ba\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); screen.assert_process(b"\x1b[7;7H\x1b[?2J"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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[2J\x1b[H"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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"foo\x1b[5;5Hbar\x1b[10;10Hbaz\x1b[20;20Hquux"); assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n bar\n\n\n\n\n baz\n\n\n\n\n\n\n\n\n\n quux\n\n\n\n\n"); @@ -147,9 +171,14 @@ fn ed() { #[test] fn el() { let mut screen = vt100::Screen::new(24, 80); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\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"foo\x1b[5;5Hbarbar\x1b[10;10Hbazbaz\x1b[20;20Hquux"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\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"foo\x1b[5;5Hbarbar\x1b[10;10Hbazbaz\x1b[20;20Hquux", + ); assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n barbar\n\n\n\n\n bazbaz\n\n\n\n\n\n\n\n\n\n quux\n\n\n\n\n"); screen.assert_process(b"\x1b[5;8H\x1b[0K"); @@ -165,9 +194,14 @@ fn el() { assert_eq!(screen.window_contents(0, 0, 23, 79), "f\n\n\n\n bar\n\n\n\n\n baz\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); screen.assert_process(b"\x1b[2J\x1b[H"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\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"foo\x1b[5;5Hbarbar\x1b[10;10Hbazbaz\x1b[20;20Hquux"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\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"foo\x1b[5;5Hbarbar\x1b[10;10Hbazbaz\x1b[20;20Hquux", + ); assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\n\n\n\n barbar\n\n\n\n\n bazbaz\n\n\n\n\n\n\n\n\n\n quux\n\n\n\n\n"); screen.assert_process(b"\x1b[5;8H\x1b[?0K"); @@ -186,90 +220,153 @@ fn el() { #[test] fn ich_dch_ech() { let mut screen = vt100::Screen::new(24, 80); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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[10;10Hfoobar"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); screen.assert_process(b"\x1b[10;12H\x1b[3@"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n fo obar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n fo obar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 11)); screen.assert_process(b"\x1b[4P"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n fobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n fobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 11)); screen.assert_process(b"\x1b[100@"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n fo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n fo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 11)); screen.assert_process(b"obar"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 15)); screen.assert_process(b"\x1b[10;12H\x1b[100P"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n fo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n fo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 11)); screen.assert_process(b"obar"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 15)); screen.assert_process(b"\x1b[10;13H\x1b[X"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n foo ar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n foo ar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 12)); screen.assert_process(b"\x1b[10;11H\x1b[4X"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n f r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n f r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 10)); screen.assert_process(b"\x1b[10;11H\x1b[400X"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n f\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n f\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 10)); } #[test] fn il_dl() { let mut screen = vt100::Screen::new(24, 80); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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[10;10Hfoobar\x1b[3D"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 12)); screen.assert_process(b"\x1b[L"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 12)); screen.assert_process(b"\x1b[3L"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (9, 12)); screen.assert_process(b"\x1b[500L"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\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(), (9, 12)); screen.assert_process(b"\x1b[10;10Hfoobar\x1b[3D\x1b[6A"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (3, 12)); screen.assert_process(b"\x1b[M"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (3, 12)); screen.assert_process(b"\x1b[3M"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "\n\n\n\n\n foobar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); assert_eq!(screen.cursor_position(), (3, 12)); screen.assert_process(b"\x1b[500M"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\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(), (3, 12)); } #[test] fn scroll() { let mut screen = vt100::Screen::new(24, 80); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\n\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"1\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"); diff --git a/tests/escape.rs b/tests/escape.rs index acbad5c..4c01c82 100644 --- a/tests/escape.rs +++ b/tests/escape.rs @@ -17,7 +17,10 @@ fn deckpam() { fn ri() { let mut screen = vt100::Screen::new(24, 80); screen.assert_process(b"foo\nbar\x1bMbaz"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "foo baz\n bar\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.window_contents(0, 0, 23, 79), + "foo baz\n bar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] @@ -28,8 +31,14 @@ fn ris() { let cell = screen.cell(0, 0).unwrap(); assert_eq!(cell.contents(), ""); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents_formatted(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\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.window_contents_formatted(0, 0, 23, 79), + "\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.title(), None); assert_eq!(screen.icon_name(), None); @@ -60,7 +69,10 @@ fn ris() { let cell = screen.cell(0, 0).unwrap(); assert_eq!(cell.contents(), "f"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "foo\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.window_contents(0, 0, 23, 79), + "foo\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.window_contents_formatted(0, 0, 23, 79), "f\x1b[31;47;1;3;4moo\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.title().unwrap(), "window title"); @@ -91,8 +103,14 @@ fn ris() { let cell = screen.cell(0, 0).unwrap(); assert_eq!(cell.contents(), ""); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents_formatted(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\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.window_contents_formatted(0, 0, 23, 79), + "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); // title and icon name don't change with reset assert_eq!(screen.title().unwrap(), "window title"); @@ -131,5 +149,8 @@ fn vb() { fn decsc() { let mut screen = vt100::Screen::new(24, 80); screen.assert_process(b"foo\x1b7\r\n\r\n\r\n bar\x1b8baz"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "foobaz\n\n\n bar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + assert_eq!( + screen.window_contents(0, 0, 23, 79), + "foobaz\n\n\n bar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } diff --git a/tests/init.rs b/tests/init.rs index eb71a43..eb3179a 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -16,8 +16,14 @@ fn init() { let cell = screen.cell(0, 80); assert!(cell.is_none()); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents_formatted(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\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.window_contents_formatted(0, 0, 23, 79), + "\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.title(), None); assert_eq!(screen.icon_name(), None); diff --git a/tests/mode.rs b/tests/mode.rs index 19658b2..50f18ba 100644 --- a/tests/mode.rs +++ b/tests/mode.rs @@ -199,10 +199,16 @@ fn alternate_buffer() { 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!(!screen.alternate_buffer_active()); screen.assert_process(b"\x1b[?1049h"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "\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.window_contents(0, 0, 23, 79), + "\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!(screen.alternate_buffer_active()); screen.assert_process(b"foobar"); - assert_eq!(screen.window_contents(0, 0, 23, 79), "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.window_contents(0, 0, 23, 79), + "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" + ); screen.assert_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!(!screen.alternate_buffer_active()); diff --git a/tests/text.rs b/tests/text.rs index 5e33e0d..13bd96c 100644 --- a/tests/text.rs +++ b/tests/text.rs @@ -12,8 +12,14 @@ fn ascii() { 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.window_contents(0, 0, 23, 79), "foo\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.window_contents(0, 0, 500, 500), "foo\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.window_contents(0, 0, 23, 79), + "foo\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.window_contents(0, 0, 500, 500), + "foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] @@ -26,8 +32,14 @@ fn utf8() { assert_eq!(screen.cell(0, 3).unwrap().contents(), "é"); assert_eq!(screen.cell(0, 4).unwrap().contents(), ""); assert_eq!(screen.cell(1, 0).unwrap().contents(), ""); - assert_eq!(screen.window_contents(0, 0, 23, 79), "café\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.window_contents(0, 0, 500, 500), "café\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.window_contents(0, 0, 23, 79), + "café\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.window_contents(0, 0, 500, 500), + "café\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] @@ -45,8 +57,14 @@ fn newlines() { assert_eq!(screen.cell(2, 2).unwrap().contents(), "d"); assert_eq!(screen.cell(0, 3).unwrap().contents(), ""); assert_eq!(screen.cell(3, 0).unwrap().contents(), ""); - assert_eq!(screen.window_contents(0, 0, 23, 79), "f\noo\nood\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.window_contents(0, 0, 500, 500), "f\noo\nood\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.window_contents(0, 0, 23, 79), + "f\noo\nood\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.window_contents(0, 0, 500, 500), + "f\noo\nood\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] @@ -61,8 +79,14 @@ fn wide() { assert_eq!(screen.cell(0, 5).unwrap().contents(), ""); assert_eq!(screen.cell(0, 6).unwrap().contents(), ""); assert_eq!(screen.cell(1, 0).unwrap().contents(), ""); - assert_eq!(screen.window_contents(0, 0, 23, 79), "aデbネ\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.window_contents(0, 0, 500, 500), "aデbネ\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.window_contents(0, 0, 23, 79), + "aデbネ\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.window_contents(0, 0, 500, 500), + "aデbネ\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + ); } #[test] |