Commit b938cf60 authored by Matthew Nicholson's avatar Matthew Nicholson
Browse files

add more tests around change and delete with word movements

parent b8e75137
......@@ -2368,6 +2368,25 @@ mod tests {
assert_eq!(ed.cursor(), end_pos);
}
#[test]
/// test delete word
fn delete_word() {
let mut context = Context::new();
let out = Vec::new();
let ed = Editor::new(out, "prompt".to_owned(), &mut context).unwrap();
let mut map = Vi::new(ed);
map.ed.insert_str_after_cursor("delete some words").unwrap();
simulate_keys!(map, [
Esc,
Char('0'),
Char('d'),
Char('w'),
]);
assert_eq!(map.ed.cursor(), 0);
assert_eq!(String::from(map), "some words");
}
#[test]
/// test changing a line
fn change_line() {
......@@ -2641,6 +2660,59 @@ mod tests {
assert_eq!(String::from(map), "ochange");
}
#[test]
/// test change word
fn change_word() {
let mut context = Context::new();
let out = Vec::new();
let ed = Editor::new(out, "prompt".to_owned(), &mut context).unwrap();
let mut map = Vi::new(ed);
map.ed.insert_str_after_cursor("change some words").unwrap();
simulate_keys!(map, [
Esc,
Char('0'),
Char('c'),
Char('w'),
Char('t'),
Char('w'),
Char('e'),
Char('a'),
Char('k'),
Char(' '),
]);
assert_eq!(String::from(map), "tweak some words");
}
#[test]
/// make sure the count is properly reset
fn test_count_reset_around_insert_and_delete() {
let mut context = Context::new();
let out = Vec::new();
let ed = Editor::new(out, "prompt".to_owned(), &mut context).unwrap();
let mut map = Vi::new(ed);
map.ed.insert_str_after_cursor("these are some words").unwrap();
simulate_keys!(map, [
Esc,
Char('0'),
Char('d'),
Char('3'),
Char('w'),
Char('i'),
Char('w'),
Char('o'),
Char('r'),
Char('d'),
Char('s'),
Char(' '),
Esc,
Char('l'),
Char('.'),
]);
assert_eq!(String::from(map), "words words words");
}
#[test]
/// undo with counts
fn test_undo_with_counts() {
......@@ -2684,6 +2756,31 @@ mod tests {
assert_eq!(String::from(map), "abcde");
}
#[test]
/// test change word with 'gE'
fn change_word_ge_ws() {
let mut context = Context::new();
let out = Vec::new();
let ed = Editor::new(out, "prompt".to_owned(), &mut context).unwrap();
let mut map = Vi::new(ed);
map.ed.insert_str_after_cursor("change some words").unwrap();
simulate_keys!(map, [
Esc,
Char('c'),
Char('g'),
Char('E'),
Char('e'),
Char('t'),
Char('h'),
Char('i'),
Char('n'),
Char('g'),
Esc,
]);
assert_eq!(String::from(map), "change something");
}
#[test]
/// test undo in groups
fn undo_insert() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment