add some more tests

This commit is contained in:
Wez Furlong committed 2018-02-12 08:25:31 -08:00
1 parent 28179ff981
commit 20f4b21f13
2 files changed
+35 -1

No files matched your search

+34
View File
@@ -15,6 +15,8 @@ fn test_vpa() {
// when we parse them!
term.print("\x1b[2d");
term.assert_cursor_pos(0, 1, None);
term.print("\x1b[-2d");
term.assert_cursor_pos(0, 1, None);
}
#[test]
@@ -30,3 +32,35 @@ fn test_ech() {
term.print("\x1b[-12X");
assert_visible_contents(&term, &["h ", "wat?", " "]);
}
#[test]
fn test_cup() {
let mut term = TestTerm::new(3, 4, 0);
term.cup(1, 1);
term.assert_cursor_pos(1, 1, None);
term.cup(-1, -1);
term.assert_cursor_pos(0, 0, None);
term.cup(2, 2);
term.assert_cursor_pos(2, 2, None);
term.cup(-1, -1);
term.assert_cursor_pos(0, 0, None);
term.cup(500, 500);
term.assert_cursor_pos(3, 2, None);
}
#[test]
fn test_dl() {
let mut term = TestTerm::new(3, 1, 0);
term.print("a\nb\nc");
term.cup(0, 1);
term.delete_lines(1);
assert_visible_contents(&term, &["a", "c", " "]);
term.assert_cursor_pos(0, 1, None);
term.cup(0, 0);
term.delete_lines(2);
assert_visible_contents(&term, &[" ", " ", " "]);
term.print("1\n2\n3");
term.cup(0, 1);
term.delete_lines(-2);
assert_visible_contents(&term, &["1", "2", "3"]);
}
+1 -1
View File
@@ -72,7 +72,7 @@ impl TestTerm {
self.print(format!("{};{}r", top + 1, bottom + 1));
}
fn delete_lines(&mut self, n: usize) {
fn delete_lines(&mut self, n: isize) {
self.print(CSI);
self.print(format!("{}M", n));
}