From 665238f5318bee40f254fe43aa158e61bdd25392 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 5 Nov 2019 10:26:19 -0500 Subject: contents_formatted should return a Vec the overall terminal escape sequence byte stream is not necessarily utf8-safe, even if individual cell contents are --- tests/window_contents.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/window_contents.rs') diff --git a/tests/window_contents.rs b/tests/window_contents.rs index 898351e..5fe0cda 100644 --- a/tests/window_contents.rs +++ b/tests/window_contents.rs @@ -2,7 +2,7 @@ fn formatted() { let mut parser = vt100::Parser::new(24, 80); compare_formatted(&parser); - assert_eq!(parser.screen().contents_formatted(0, 0, 23, 79), ""); + assert_eq!(parser.screen().contents_formatted(0, 0, 23, 79), b""); parser.process(b"foobar"); compare_formatted(&parser); @@ -10,7 +10,7 @@ fn formatted() { assert!(!parser.screen().cell(0, 3).unwrap().bold()); assert!(!parser.screen().cell(0, 4).unwrap().bold()); assert!(!parser.screen().cell(0, 5).unwrap().bold()); - assert_eq!(parser.screen().contents_formatted(0, 0, 23, 79), "foobar"); + assert_eq!(parser.screen().contents_formatted(0, 0, 23, 79), b"foobar"); parser.process(b"\x1b[1;4H\x1b[1;7m\x1b[33mb"); compare_formatted(&parser); @@ -20,7 +20,7 @@ fn formatted() { assert!(!parser.screen().cell(0, 5).unwrap().bold()); assert_eq!( parser.screen().contents_formatted(0, 0, 23, 79), - "foo\x1b[33;1;7mb\x1b[mar" + b"foo\x1b[33;1;7mb\x1b[mar" ); parser.process(b"\x1b[1;5H\x1b[22;42ma"); @@ -31,27 +31,27 @@ fn formatted() { assert!(!parser.screen().cell(0, 5).unwrap().bold()); assert_eq!( parser.screen().contents_formatted(0, 0, 23, 79), - "foo\x1b[33;1;7mb\x1b[42;22ma\x1b[mr" + b"foo\x1b[33;1;7mb\x1b[42;22ma\x1b[mr" ); parser.process(b"\x1b[1;6H\x1b[35mr\r\nquux"); compare_formatted(&parser); assert_eq!( parser.screen().contents_formatted(0, 0, 23, 79), - "foo\x1b[33;1;7mb\x1b[42;22ma\x1b[35mr\r\nquux" + &b"foo\x1b[33;1;7mb\x1b[42;22ma\x1b[35mr\r\nquux"[..] ); parser.process(b"\x1b[2;1H\x1b[45mquux"); compare_formatted(&parser); assert_eq!( parser.screen().contents_formatted(0, 0, 23, 79), - "foo\x1b[33;1;7mb\x1b[42;22ma\x1b[35mr\r\n\x1b[45mquux" + &b"foo\x1b[33;1;7mb\x1b[42;22ma\x1b[35mr\r\n\x1b[45mquux"[..] ); parser .process(b"\x1b[2;2H\x1b[38;2;123;213;231mu\x1b[38;5;254mu\x1b[39mx"); compare_formatted(&parser); - assert_eq!(parser.screen().contents_formatted(0, 0 ,23, 79), "foo\x1b[33;1;7mb\x1b[42;22ma\x1b[35mr\r\n\x1b[45mq\x1b[38;2;123;213;231mu\x1b[38;5;254mu\x1b[39mx"); + assert_eq!(parser.screen().contents_formatted(0, 0 ,23, 79), &b"foo\x1b[33;1;7mb\x1b[42;22ma\x1b[35mr\r\n\x1b[45mq\x1b[38;2;123;213;231mu\x1b[38;5;254mu\x1b[39mx"[..]); } fn compare_formatted(parser: &vt100::Parser) { @@ -59,7 +59,7 @@ fn compare_formatted(parser: &vt100::Parser) { let contents = parser.screen().contents_formatted(0, 0, rows - 1, cols - 1); let mut parser2 = vt100::Parser::new(rows, cols); - parser2.process(contents.as_bytes()); + parser2.process(&contents); compare_cells(parser, &parser2); } -- cgit v1.2.3-54-g00ecf