More tests
diff --git a/src/test/common.rs b/src/test/common.rs
index cddeb91..2d5a959 100644
--- a/src/test/common.rs
+++ b/src/test/common.rs
@@ -97,14 +97,14 @@
#[test]
fn ctrl_u() {
assert_cursor(
- ("a", "b"),
+ ("start of line ", "end"),
&[KeyPress::Ctrl('U'), KeyPress::Enter],
- ("", "b"),
+ ("", "end"),
);
assert_cursor(
- ("", "a"),
+ ("", "end"),
&[KeyPress::Ctrl('U'), KeyPress::Enter],
- ("", "a"),
+ ("", "end"),
);
}
diff --git a/src/test/emacs.rs b/src/test/emacs.rs
index 736fd43..6494b1a 100644
--- a/src/test/emacs.rs
+++ b/src/test/emacs.rs
@@ -27,6 +27,21 @@
&[KeyPress::Ctrl('B'), KeyPress::Enter],
("H", "i"),
);
+ assert_cursor(
+ ("Hi", ""),
+ &[KeyPress::Meta('2'), KeyPress::Ctrl('B'), KeyPress::Enter],
+ ("", "Hi"),
+ );
+ assert_cursor(
+ ("", "Hi"),
+ &[
+ KeyPress::Meta('-'),
+ KeyPress::Meta('2'),
+ KeyPress::Ctrl('B'),
+ KeyPress::Enter,
+ ],
+ ("Hi", ""),
+ );
}
#[test]
@@ -36,6 +51,21 @@
&[KeyPress::Ctrl('F'), KeyPress::Enter],
("H", "i"),
);
+ assert_cursor(
+ ("", "Hi"),
+ &[KeyPress::Meta('2'), KeyPress::Ctrl('F'), KeyPress::Enter],
+ ("Hi", ""),
+ );
+ assert_cursor(
+ ("Hi", ""),
+ &[
+ KeyPress::Meta('-'),
+ KeyPress::Meta('2'),
+ KeyPress::Ctrl('F'),
+ KeyPress::Enter,
+ ],
+ ("", "Hi"),
+ );
}
#[test]
@@ -45,6 +75,21 @@
&[KeyPress::Ctrl('H'), KeyPress::Enter],
("H", ""),
);
+ assert_cursor(
+ ("Hi", ""),
+ &[KeyPress::Meta('2'), KeyPress::Ctrl('H'), KeyPress::Enter],
+ ("", ""),
+ );
+ assert_cursor(
+ ("", "Hi"),
+ &[
+ KeyPress::Meta('-'),
+ KeyPress::Meta('2'),
+ KeyPress::Ctrl('H'),
+ KeyPress::Enter,
+ ],
+ ("", ""),
+ );
}
#[test]
@@ -105,6 +150,16 @@
}
#[test]
+fn ctrl_t() {
+ /* FIXME
+ assert_cursor(
+ ("ab", "cd"),
+ &[KeyPress::Meta('2'), KeyPress::Ctrl('T'), KeyPress::Enter],
+ ("acdb", ""),
+ );*/
+}
+
+#[test]
fn ctrl_x_ctrl_u() {
assert_cursor(
("Hello, ", "world"),
@@ -125,6 +180,16 @@
&[KeyPress::Meta('B'), KeyPress::Enter],
("Hello, ", "world!"),
);
+ assert_cursor(
+ ("Hello, world!", ""),
+ &[KeyPress::Meta('2'), KeyPress::Meta('B'), KeyPress::Enter],
+ ("", "Hello, world!"),
+ );
+ assert_cursor(
+ ("", "Hello, world!"),
+ &[KeyPress::Meta('-'), KeyPress::Meta('B'), KeyPress::Enter],
+ ("Hello", ", world!"),
+ );
}
#[test]
@@ -134,6 +199,16 @@
&[KeyPress::Meta('F'), KeyPress::Enter],
("Hello", ", world!"),
);
+ assert_cursor(
+ ("", "Hello, world!"),
+ &[KeyPress::Meta('2'), KeyPress::Meta('F'), KeyPress::Enter],
+ ("Hello, world", "!"),
+ );
+ assert_cursor(
+ ("Hello, world!", ""),
+ &[KeyPress::Meta('-'), KeyPress::Meta('F'), KeyPress::Enter],
+ ("Hello, ", "world!"),
+ );
}
#[test]
@@ -148,6 +223,12 @@
&[KeyPress::Meta('C'), KeyPress::Enter],
("Hi", ""),
);
+ /* FIXME
+ assert_cursor(
+ ("", "hi test"),
+ &[KeyPress::Meta('2'), KeyPress::Meta('C'), KeyPress::Enter],
+ ("Hi Test", ""),
+ );*/
}
#[test]
@@ -162,6 +243,12 @@
&[KeyPress::Meta('L'), KeyPress::Enter],
("hi", ""),
);
+ /* FIXME
+ assert_cursor(
+ ("", "HI TEST"),
+ &[KeyPress::Meta('2'), KeyPress::Meta('L'), KeyPress::Enter],
+ ("hi test", ""),
+ );*/
}
#[test]
@@ -176,6 +263,12 @@
&[KeyPress::Meta('U'), KeyPress::Enter],
("HI", ""),
);
+ /* FIXME
+ assert_cursor(
+ ("", "hi test"),
+ &[KeyPress::Meta('2'), KeyPress::Meta('U'), KeyPress::Enter],
+ ("HI TEST", ""),
+ );*/
}
#[test]
@@ -185,6 +278,11 @@
&[KeyPress::Meta('D'), KeyPress::Enter],
("Hello", "!"),
);
+ assert_cursor(
+ ("Hello", ", world!"),
+ &[KeyPress::Meta('2'), KeyPress::Meta('D'), KeyPress::Enter],
+ ("Hello", ""),
+ );
}
#[test]
@@ -194,6 +292,12 @@
&[KeyPress::Meta('T'), KeyPress::Enter],
("world, Hello", "!"),
);
+ /* FIXME
+ assert_cursor(
+ ("One Two", " Three Four"),
+ &[KeyPress::Meta('T'), KeyPress::Enter],
+ ("One Four Three Two", ""),
+ );*/
}
#[test]
@@ -220,3 +324,12 @@
("Hello, ", "ld!"),
);
}
+
+#[test]
+fn meta_digit() {
+ assert_cursor(
+ ("", ""),
+ &[KeyPress::Meta('3'), KeyPress::Char('h'), KeyPress::Enter],
+ ("hhh", ""),
+ );
+}
diff --git a/src/test/history.rs b/src/test/history.rs
index aa9e9c6..2397884 100644
--- a/src/test/history.rs
+++ b/src/test/history.rs
@@ -15,7 +15,16 @@
&[
KeyPress::Char('a'),
KeyPress::Up,
- KeyPress::Down,
+ KeyPress::Down, // restore original line
+ KeyPress::Enter,
+ ],
+ ("a", ""),
+ );
+ assert_history(
+ &["line1"],
+ &[
+ KeyPress::Char('a'),
+ KeyPress::Down, // noop
KeyPress::Enter,
],
("a", ""),
@@ -76,10 +85,21 @@
&[
KeyPress::Ctrl('R'),
KeyPress::Char('r'),
- KeyPress::Char('z'), // no match
+ KeyPress::Ctrl('R'),
KeyPress::Right, // just to assert cursor pos
KeyPress::Enter,
],
+ ("r", "ustc"),
+ );
+ assert_history(
+ &["rustc", "cargo"],
+ &[
+ KeyPress::Ctrl('R'),
+ KeyPress::Char('r'),
+ KeyPress::Char('z'), // no match
+ KeyPress::Right, // just to assert cursor pos
+ KeyPress::Enter,
+ ],
("car", "go"),
);
assert_history(
@@ -96,6 +116,22 @@
}
#[test]
+fn ctrl_s() {
+ assert_history(
+ &["rustc", "cargo"],
+ &[
+ KeyPress::Ctrl('R'),
+ KeyPress::Char('r'),
+ KeyPress::Ctrl('R'),
+ KeyPress::Ctrl('S'),
+ KeyPress::Right, // just to assert cursor pos
+ KeyPress::Enter,
+ ],
+ ("car", "go"),
+ );
+}
+
+#[test]
fn meta_lt() {
assert_history(&[""], &[KeyPress::Meta('<'), KeyPress::Enter], ("", ""));
assert_history(
@@ -118,7 +154,7 @@
&[
KeyPress::Char('a'),
KeyPress::Meta('<'),
- KeyPress::Meta('>'),
+ KeyPress::Meta('>'), // restore original line
KeyPress::Enter,
],
("a", ""),