aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-10-29 13:42:00 -0400
committerJesse Luehrs <doy@tozt.net>2019-10-29 13:42:00 -0400
commitf84638fd816d2295c5d9f60c0ac8eb6df50d1aba (patch)
tree4562b26f23283710e454d257114813be1623ea1d /tests
parente525fddb572614f4c6d6a7d71ed44e9dfe7af350 (diff)
downloadvt100-rust-f84638fd816d2295c5d9f60c0ac8eb6df50d1aba.tar.gz
vt100-rust-f84638fd816d2295c5d9f60c0ac8eb6df50d1aba.zip
start the rewrite
Diffstat (limited to 'tests')
-rw-r--r--tests/attr.rs137
-rw-r--r--tests/basic.rs24
-rw-r--r--tests/control.rs2
-rw-r--r--tests/csi.rs2
-rw-r--r--tests/escape.rs14
-rw-r--r--tests/init.rs8
-rw-r--r--tests/mode.rs2
-rw-r--r--tests/osc.rs2
-rw-r--r--tests/processing.rs2
-rw-r--r--tests/scroll.rs2
-rw-r--r--tests/split-escapes.rs8
-rw-r--r--tests/support/mod.rs8
-rw-r--r--tests/text.rs2
-rw-r--r--tests/zero-width.rs2
14 files changed, 69 insertions, 146 deletions
diff --git a/tests/attr.rs b/tests/attr.rs
index 2532819..e621098 100644
--- a/tests/attr.rs
+++ b/tests/attr.rs
@@ -1,4 +1,4 @@
-extern crate vt100;
+#![allow(clippy::cognitive_complexity)]
mod support;
use support::TestHelpers;
@@ -6,164 +6,113 @@ use support::TestHelpers;
#[test]
fn colors() {
let mut screen = vt100::Screen::new(24, 80);
- assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault);
- assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault);
+ assert_eq!(screen.fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.bgcolor(), vt100::Color::Default);
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::Default);
+ assert_eq!(screen.cell(0, 0).unwrap().bgcolor(), vt100::Color::Default);
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::Idx(1));
+ assert_eq!(screen.cell(0, 3).unwrap().bgcolor(), vt100::Color::Default);
- assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(1));
- assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault);
+ assert_eq!(screen.fgcolor(), vt100::Color::Idx(1));
+ assert_eq!(screen.bgcolor(), vt100::Color::Default);
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::Idx(1));
+ assert_eq!(screen.cell(0, 4).unwrap().bgcolor(), vt100::Color::Idx(5));
- assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(1));
- assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(5));
+ assert_eq!(screen.fgcolor(), vt100::Color::Idx(1));
+ assert_eq!(screen.bgcolor(), vt100::Color::Idx(5));
screen.assert_process(b"\x1b[m");
- assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault);
- assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault);
+ assert_eq!(screen.fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.bgcolor(), vt100::Color::Default);
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
+ vt100::Color::Default
);
assert_eq!(
screen.cell(14, 14).unwrap().bgcolor(),
- vt100::Color::ColorDefault
+ vt100::Color::Default
);
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().fgcolor(), vt100::Color::Idx(1));
assert_eq!(
screen.cell(14, 17).unwrap().bgcolor(),
- vt100::Color::ColorDefault
+ vt100::Color::Default
);
- assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault);
- assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault);
+ assert_eq!(screen.fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.bgcolor(), vt100::Color::Default);
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)
+ vt100::Color::Default
);
+ assert_eq!(screen.cell(14, 18).unwrap().bgcolor(), vt100::Color::Idx(5));
- assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault);
- assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(5));
+ assert_eq!(screen.fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.bgcolor(), vt100::Color::Idx(5));
screen.assert_process(b"\x1b[m\x1b[2J\x1b[H");
screen.assert_process(b"a\x1b[38;5;123mb\x1b[48;5;158mc");
- assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(123));
- assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(158));
+ assert_eq!(screen.fgcolor(), vt100::Color::Idx(123));
+ assert_eq!(screen.bgcolor(), vt100::Color::Idx(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, 0).unwrap().fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.cell(0, 0).unwrap().bgcolor(), vt100::Color::Default);
- 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, 1).unwrap().fgcolor(), vt100::Color::Idx(123));
+ assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::Default);
- 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, 2).unwrap().fgcolor(), vt100::Color::Idx(123));
+ assert_eq!(screen.cell(0, 2).unwrap().bgcolor(), vt100::Color::Idx(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.fgcolor(), vt100::Color::Rgb(50, 75, 100));
+ assert_eq!(screen.bgcolor(), vt100::Color::Rgb(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)
+ vt100::Color::Rgb(50, 75, 100)
);
+ assert_eq!(screen.cell(0, 3).unwrap().bgcolor(), vt100::Color::Idx(158));
assert_eq!(
screen.cell(0, 4).unwrap().fgcolor(),
- vt100::Color::ColorRgb(50, 75, 100)
+ vt100::Color::Rgb(50, 75, 100)
);
assert_eq!(
screen.cell(0, 4).unwrap().bgcolor(),
- vt100::Color::ColorRgb(125, 150, 175)
+ vt100::Color::Rgb(125, 150, 175)
);
screen.assert_process(b"\x1b[m\x1b[2J\x1b[H");
screen.assert_process(b"\x1b[32;47mfoo");
- assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(2));
- assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(7));
+ assert_eq!(screen.fgcolor(), vt100::Color::Idx(2));
+ assert_eq!(screen.bgcolor(), vt100::Color::Idx(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::Idx(2));
+ assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::Idx(7));
}
#[test]
diff --git a/tests/basic.rs b/tests/basic.rs
index babec39..46d9265 100644
--- a/tests/basic.rs
+++ b/tests/basic.rs
@@ -1,5 +1,3 @@
-extern crate vt100;
-
#[test]
fn object_creation() {
let screen = vt100::Screen::new(24, 80);
@@ -17,7 +15,7 @@ fn process_text() {
#[test]
fn set_window_size() {
- let screen = vt100::Screen::new(24, 80);
+ let mut screen = vt100::Screen::new(24, 80);
assert_eq!(screen.rows(), 24);
assert_eq!(screen.cols(), 80);
@@ -46,22 +44,10 @@ fn cell_colors() {
let input = b"foo\x1b[31m\x1b[32mb\x1b[3;7;42ma\x1b[23mr";
screen.process(input);
- assert_eq!(
- screen.cell(0, 0).unwrap().fgcolor(),
- vt100::Color::ColorDefault
- );
- assert_eq!(
- screen.cell(0, 3).unwrap().fgcolor(),
- vt100::Color::ColorIdx(2)
- );
- assert_eq!(
- screen.cell(0, 4).unwrap().fgcolor(),
- vt100::Color::ColorIdx(2)
- );
- assert_eq!(
- screen.cell(0, 4).unwrap().bgcolor(),
- vt100::Color::ColorIdx(2)
- );
+ assert_eq!(screen.cell(0, 0).unwrap().fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.cell(0, 3).unwrap().fgcolor(), vt100::Color::Idx(2));
+ assert_eq!(screen.cell(0, 4).unwrap().fgcolor(), vt100::Color::Idx(2));
+ assert_eq!(screen.cell(0, 4).unwrap().bgcolor(), vt100::Color::Idx(2));
}
#[test]
diff --git a/tests/control.rs b/tests/control.rs
index 787bdc2..82b996c 100644
--- a/tests/control.rs
+++ b/tests/control.rs
@@ -1,5 +1,3 @@
-extern crate vt100;
-
mod support;
use support::TestHelpers;
diff --git a/tests/csi.rs b/tests/csi.rs
index e19f377..519fc94 100644
--- a/tests/csi.rs
+++ b/tests/csi.rs
@@ -1,5 +1,3 @@
-extern crate vt100;
-
mod support;
use support::TestHelpers;
diff --git a/tests/escape.rs b/tests/escape.rs
index 4c01c82..6661188 100644
--- a/tests/escape.rs
+++ b/tests/escape.rs
@@ -1,4 +1,4 @@
-extern crate vt100;
+#![allow(clippy::cognitive_complexity)]
mod support;
use support::TestHelpers;
@@ -43,8 +43,8 @@ fn ris() {
assert_eq!(screen.title(), None);
assert_eq!(screen.icon_name(), None);
- assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault);
- assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault);
+ assert_eq!(screen.fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.bgcolor(), vt100::Color::Default);
assert!(!screen.bold());
assert!(!screen.italic());
@@ -78,8 +78,8 @@ fn ris() {
assert_eq!(screen.title().unwrap(), "window title");
assert_eq!(screen.icon_name().unwrap(), "window icon name");
- assert_eq!(screen.fgcolor(), vt100::Color::ColorIdx(1));
- assert_eq!(screen.bgcolor(), vt100::Color::ColorIdx(7));
+ assert_eq!(screen.fgcolor(), vt100::Color::Idx(1));
+ assert_eq!(screen.bgcolor(), vt100::Color::Idx(7));
assert!(screen.bold());
assert!(screen.italic());
@@ -116,8 +116,8 @@ fn ris() {
assert_eq!(screen.title().unwrap(), "window title");
assert_eq!(screen.icon_name().unwrap(), "window icon name");
- assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault);
- assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault);
+ assert_eq!(screen.fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.bgcolor(), vt100::Color::Default);
assert!(!screen.bold());
assert!(!screen.italic());
diff --git a/tests/init.rs b/tests/init.rs
index eb3179a..f5c896a 100644
--- a/tests/init.rs
+++ b/tests/init.rs
@@ -1,8 +1,8 @@
-extern crate vt100;
+#![allow(clippy::cognitive_complexity)]
#[test]
fn init() {
- let screen = vt100::Screen::new(24, 80);
+ let mut screen = vt100::Screen::new(24, 80);
assert_eq!(screen.rows(), 24);
assert_eq!(screen.cols(), 80);
assert_eq!(screen.cursor_position(), (0, 0));
@@ -28,8 +28,8 @@ fn init() {
assert_eq!(screen.title(), None);
assert_eq!(screen.icon_name(), None);
- assert_eq!(screen.fgcolor(), vt100::Color::ColorDefault);
- assert_eq!(screen.bgcolor(), vt100::Color::ColorDefault);
+ assert_eq!(screen.fgcolor(), vt100::Color::Default);
+ assert_eq!(screen.bgcolor(), vt100::Color::Default);
assert!(!screen.bold());
assert!(!screen.italic());
diff --git a/tests/mode.rs b/tests/mode.rs
index 50f18ba..5f8b2a4 100644
--- a/tests/mode.rs
+++ b/tests/mode.rs
@@ -1,4 +1,4 @@
-extern crate vt100;
+#![allow(clippy::cognitive_complexity)]
mod support;
use support::TestHelpers;
diff --git a/tests/osc.rs b/tests/osc.rs
index 59ab943..be3c476 100644
--- a/tests/osc.rs
+++ b/tests/osc.rs
@@ -1,5 +1,3 @@
-extern crate vt100;
-
mod support;
use support::TestHelpers;
diff --git a/tests/processing.rs b/tests/processing.rs
index 02c2766..3110814 100644
--- a/tests/processing.rs
+++ b/tests/processing.rs
@@ -1,4 +1,4 @@
-extern crate vt100;
+#![allow(clippy::cognitive_complexity)]
#[test]
fn split_escape_sequences() {
diff --git a/tests/scroll.rs b/tests/scroll.rs
index b5a8891..3ac0074 100644
--- a/tests/scroll.rs
+++ b/tests/scroll.rs
@@ -1,5 +1,3 @@
-extern crate vt100;
-
mod support;
use support::TestHelpers;
diff --git a/tests/split-escapes.rs b/tests/split-escapes.rs
index bd7d20a..33f3c0d 100644
--- a/tests/split-escapes.rs
+++ b/tests/split-escapes.rs
@@ -1,6 +1,4 @@
-extern crate vt100;
-
-use std::io::prelude::*;
+use std::io::Read as _;
fn get_file_contents(name: &str) -> Vec<u8> {
let mut file = std::fs::File::open(name).unwrap();
@@ -14,8 +12,8 @@ fn write_to_screen(chunks: &mut Vec<Vec<u8>>) -> String {
let mut full_chunk = vec![];
for chunk in chunks.iter_mut() {
full_chunk.append(chunk);
- let bytes = screen.process(&mut full_chunk);
- full_chunk = full_chunk.split_off(bytes as usize);
+ let bytes = screen.process(&full_chunk);
+ full_chunk = full_chunk.split_off(bytes);
}
assert_eq!(full_chunk.len(), 0);
screen.window_contents(0, 0, 36, 192)
diff --git a/tests/support/mod.rs b/tests/support/mod.rs
index 51ad600..cfa6320 100644
--- a/tests/support/mod.rs
+++ b/tests/support/mod.rs
@@ -1,13 +1,11 @@
-use vt100;
-
pub trait TestHelpers {
- fn assert_process(&mut self, s: &[u8]) -> u64;
+ fn assert_process(&mut self, s: &[u8]) -> usize;
}
impl TestHelpers for vt100::Screen {
- fn assert_process(&mut self, s: &[u8]) -> u64 {
+ fn assert_process(&mut self, s: &[u8]) -> usize {
let ret = self.process(s);
- assert_eq!(ret, s.len() as u64);
+ assert_eq!(ret, s.len());
ret
}
}
diff --git a/tests/text.rs b/tests/text.rs
index 13bd96c..140b32f 100644
--- a/tests/text.rs
+++ b/tests/text.rs
@@ -1,4 +1,4 @@
-extern crate vt100;
+#![allow(clippy::cognitive_complexity)]
mod support;
use support::TestHelpers;
diff --git a/tests/zero-width.rs b/tests/zero-width.rs
index 5de6faf..0722b66 100644
--- a/tests/zero-width.rs
+++ b/tests/zero-width.rs
@@ -1,4 +1,4 @@
-extern crate vt100;
+#![allow(clippy::cognitive_complexity)]
#[test]
fn zero_width_characters() {