Files
2026-10-14 15:28:51 -03:00

123 lines
4.4 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Cursor motion contracts, including Unicode and line boundaries.
mod support;
use notescraft_vim::Mode;
#[test]
fn character_and_line_motions() {
support::check(
&[
("|abc", "l", "a|bc"),
("a|bc", "h", "|abc"),
("|abc", "h", "|abc"),
("ab|c", "l", "ab|c"),
("|abc", "2l", "ab|c"),
("ab|c", "2h", "|abc"),
("|é猫🙂", "l", "é|猫🙂"),
("é|猫🙂", "l", "é猫|🙂"),
("é猫|🙂", "h", "é|猫🙂"),
("|é猫🙂", "9l", "é猫|🙂"),
("é猫|🙂", "9h", "|é猫🙂"),
("|", "hjkl", "|"),
("|a", "hl", "|a"),
("|abc\ndef", "j", "abc\n|def"),
("a|bc\ndef", "j", "abc\nd|ef"),
("ab|c\nd", "j", "abc\n|d"),
("abc\nd|ef", "k", "a|bc\ndef"),
("|abc\ndef", "k", "|abc\ndef"),
("abc\n|def", "j", "abc\n|def"),
("|a\nb\nc", "2j", "a\nb\n|c"),
("a\nb\n|c", "2k", "|a\nb\nc"),
("é|猫\nαβ", "j", "é猫\nα|β"),
("abc\n|\ndef", "j", "abc\n\n|def"),
("|abc", "<Right>", "a|bc"),
("a|bc", "<Left>", "|abc"),
("|abc\ndef", "<Down>", "abc\n|def"),
("abc\n|def", "<Up>", "|abc\ndef"),
("ab|c", "0", "|abc"),
(" a|bc", "^", " |abc"),
(" |abc", "^", " |abc"),
("|abc", "$", "ab|c"),
("|é猫🙂", "$", "é猫|🙂"),
("a\n|b", "gg", "|a\nb"),
("|a\nb\nc", "G", "a\nb\n|c"),
("|a\nb\nc", "2G", "a\n|b\nc"),
("a\nb\n|c", "2gg", "a\n|b\nc"),
("abc\nd|ef", "<Home>", "abc\n|def"),
("abc\n|def", "<End>", "abc\nde|f"),
],
Mode::Normal,
);
}
#[test]
fn word_and_paragraph_motions() {
support::check(
&[
("|one two", "w", "one |two"),
("|one two three", "2w", "one two |three"),
("one |two", "b", "|one two"),
("one tw|o", "b", "one |two"),
("|one two", "e", "on|e two"),
("on|e two", "e", "one tw|o"),
("|one two three", "2e", "one tw|o three"),
("|one,two", "w", "one|,two"),
("one|,two", "w", "one,|two"),
("one,|two", "b", "one|,two"),
("|one,two", "W", "one,tw|o"),
("|one,two next", "W", "one,two |next"),
("one,two |next", "B", "|one,two next"),
("one,t|wo next", "B", "|one,two next"),
("|one,two next", "E", "one,tw|o next"),
("one,tw|o next", "E", "one,two nex|t"),
("|éé 猫猫 🙂", "w", "éé |猫猫 🙂"),
("éé |猫猫 🙂", "b", "|éé 猫猫 🙂"),
("|éé 猫猫", "e", "é|é 猫猫"),
("|éé,猫猫 next", "W", "éé,猫猫 |next"),
("| one two", "w", " |one two"),
("|one\ntwo", "w", "one\n|two"),
("one\n|two", "b", "|one\ntwo"),
("|a", "webWE", "|a"),
("|one\n\ntwo", "}", "one\n|\ntwo"),
("one\n\n|two", "{", "one\n|\ntwo"),
("|a\n\nb\n\nc", "2}", "a\n\nb\n|\nc"),
("a\n\nb\n\n|c", "2{", "a\n|\nb\n\nc"),
],
Mode::Normal,
);
}
#[test]
fn find_pair_and_mark_motions() {
support::check(
&[
("|abcabc", "fc", "ab|cabc"),
("|abcabc", "2fc", "abcab|c"),
("abca|bc", "Fa", "abc|abc"),
("abcab|c", "2Fa", "|abcabc"),
("|abcabc", "tc", "a|bcabc"),
("abcab|c", "Ta", "abca|bc"),
("|abcabc", "fc;", "abcab|c"),
("|abcabc", "fc;,", "ab|cabc"),
("|abc", "fz", "|abc"),
("|abc\ndef", "fd", "|abc\ndef"),
("|é猫🙂猫", "f猫", "é|猫🙂猫"),
("|é猫🙂猫", "2f猫", "é猫🙂|猫"),
("é猫🙂|猫", "F猫", "é|猫🙂猫"),
("|é猫🙂猫", "t🙂", "é|猫🙂猫"),
("|(abc)", "%", "(abc|)"),
("(abc|)", "%", "|(abc)"),
("|[a[b]c]", "%", "[a[b]c|]"),
("|{é猫}", "%", "{é猫|}"),
("|abc", "%", "|abc"),
("|abc", "mal`a", "|abc"),
("a|bc\ndef", "maj'a", "|abc\ndef"),
(" a|bc\ndef", "maj'a", " |abc\ndef"),
("é|猫\nαβ", "maj`a", "é|猫\nαβ"),
("|abc", "'z", "|abc"),
("|abc", "`z", "|abc"),
],
Mode::Normal,
);
}