From 6900990a13743a663c25915a558a3eee269a9e9d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 16 Dec 2016 15:40:46 -0500 Subject: [PATCH] Fix tests for the new default CRLF mode --- tests/xedit.c | 216 ++++++++++++++++++++++++++------------------------ 1 file changed, 111 insertions(+), 105 deletions(-) diff --git a/tests/xedit.c b/tests/xedit.c index f29bdfc..5c203cf 100644 --- a/tests/xedit.c +++ b/tests/xedit.c @@ -1,6 +1,11 @@ #include #include +enum { + LF = 0, + CRLF = 1 +}; + // Test Globals int Mods = 0; int ExitCode = 0; @@ -15,9 +20,10 @@ void mockexit(int code) { /* Helper Functions *****************************************************************************/ -void setup_view(enum RegionId id, char* text, unsigned cursor) { +void setup_view(enum RegionId id, char* text, int crlf, unsigned cursor) { Focused = id; view_init(getview(id), NULL); + getbuf(id)->crlf = crlf; view_putstr(getview(id), text); getsel(id)->beg = cursor; getsel(id)->end = cursor; @@ -66,14 +72,14 @@ TEST_SUITE(XeditTests) { /* Key Handling - Normal Input *************************************************************************/ TEST(input not matching a shortcut should be inserted as text) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, 'e'); CHECK(getsel(EDIT)->beg == 1); CHECK(getsel(EDIT)->end == 1); } TEST(input \n chould result in RUNE_CRLF if in crlf mode) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); getbuf(EDIT)->crlf = 1; send_keys(ModNone, '\n'); CHECK(getsel(EDIT)->beg == 1); @@ -82,7 +88,7 @@ TEST_SUITE(XeditTests) { } TEST(input \n chould result in \n if not in crlf mode) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); getbuf(EDIT)->crlf = 0; send_keys(ModNone, '\n'); CHECK(getsel(EDIT)->beg == 1); @@ -93,203 +99,203 @@ TEST_SUITE(XeditTests) { /* Key Handling - Cursor Movement - Basic *************************************************************************/ TEST(left should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_LEFT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+left should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, KEY_LEFT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(left should do nothing at beginning of buffer) { - setup_view(EDIT, "AB", 0); + setup_view(EDIT, "AB", CRLF, 0); send_keys(ModNone, KEY_LEFT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+left should do nothing at beginning of buffer) { - setup_view(EDIT, "AB", 0); + setup_view(EDIT, "AB", CRLF, 0); send_keys(ModCtrl, KEY_LEFT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+left should move left by one word) { - setup_view(EDIT, "AB CD", 3); + setup_view(EDIT, "AB CD", CRLF, 3); send_keys(ModCtrl, KEY_LEFT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(left should move left by one rune) { - setup_view(EDIT, "AB", 1); + setup_view(EDIT, "AB", CRLF, 1); send_keys(ModNone, KEY_LEFT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(right should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_RIGHT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(right should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, KEY_RIGHT); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+right should do nothing at end of buffer) { - setup_view(EDIT, "AB", 2); + setup_view(EDIT, "AB", CRLF, 2); send_keys(ModNone, KEY_RIGHT); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); } TEST(ctrl+right should do nothing at end of buffer) { - setup_view(EDIT, "AB", 2); + setup_view(EDIT, "AB", CRLF, 2); send_keys(ModCtrl, KEY_RIGHT); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); } TEST(ctrl+right should move right by one word) { - setup_view(EDIT, "AB CD", 0); + setup_view(EDIT, "AB CD", CRLF, 0); send_keys(ModCtrl, KEY_RIGHT); CHECK(getsel(EDIT)->beg == 3); CHECK(getsel(EDIT)->end == 3); } TEST(right should move right by one rune) { - setup_view(EDIT, "AB", 1); + setup_view(EDIT, "AB", CRLF, 1); send_keys(ModNone, KEY_RIGHT); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); } TEST(up should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_UP); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(up should move cursor up one line) { - setup_view(EDIT, "AB\nCD", 4); + setup_view(EDIT, "AB\nCD", CRLF, 4); send_keys(ModNone, KEY_UP); CHECK(getsel(EDIT)->beg == 1); CHECK(getsel(EDIT)->end == 1); } TEST(up should do nothing for first line) { - setup_view(EDIT, "AB\nCD", 1); + setup_view(EDIT, "AB\nCD", CRLF, 1); send_keys(ModNone, KEY_UP); CHECK(getsel(EDIT)->beg == 1); CHECK(getsel(EDIT)->end == 1); } TEST(down should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_DOWN); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(down should move down one line) { - setup_view(EDIT, "AB\nCD", 1); + setup_view(EDIT, "AB\nCD", CRLF, 1); send_keys(ModNone, KEY_DOWN); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(down should do nothing on last line) { - setup_view(EDIT, "AB\nCD", 4); + setup_view(EDIT, "AB\nCD", CRLF, 4); send_keys(ModNone, KEY_DOWN); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(home should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_HOME); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+home should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, KEY_HOME); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+home should move to beginning of buffer) { - setup_view(EDIT, "ABCD", 4); + setup_view(EDIT, "ABCD", CRLF, 4); send_keys(ModCtrl, KEY_HOME); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(home should move to beginning of indented content) { - setup_view(EDIT, " ABCD", 7); + setup_view(EDIT, " ABCD", CRLF, 7); send_keys(ModNone, KEY_HOME); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(home should move to beginning of line if at beginning of indented content) { - setup_view(EDIT, " ABCD", 7); + setup_view(EDIT, " ABCD", CRLF, 7); send_keys(ModNone, KEY_HOME); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(home should move to beginning of indented content when at beginning of line) { - setup_view(EDIT, " ABCD", 0); + setup_view(EDIT, " ABCD", CRLF, 0); send_keys(ModNone, KEY_HOME); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(end should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_END); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+end should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, KEY_END); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+end should move to end of buffer) { - setup_view(EDIT, "ABCD", 0); + setup_view(EDIT, "ABCD", CRLF, 0); send_keys(ModCtrl, KEY_END); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(end should do nothing at end of line) { - setup_view(EDIT, "AB\nCD", 2); + setup_view(EDIT, "AB\nCD", CRLF, 2); send_keys(ModNone, KEY_END); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); } TEST(end should move to end of line) { - setup_view(EDIT, "AB\nCD", 0); + setup_view(EDIT, "AB\nCD", CRLF, 0); send_keys(ModNone, KEY_END); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); @@ -298,14 +304,14 @@ TEST_SUITE(XeditTests) { /* Key Handling - Unix Editing Shortcuts *************************************************************************/ TEST(ctrl+u should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, 'u'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+u should delete to beginning of line) { - setup_view(EDIT, "\nABC\n", 2); + setup_view(EDIT, "\nABC\n", CRLF, 2); send_keys(ModCtrl, 'u'); CHECK(getsel(EDIT)->beg == 1); CHECK(getsel(EDIT)->end == 1); @@ -313,7 +319,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+u should delete entire lines contents) { - setup_view(EDIT, "\nABC\n", 3); + setup_view(EDIT, "\nABC\n", CRLF, 3); send_keys(ModCtrl, 'u'); CHECK(getsel(EDIT)->beg == 1); CHECK(getsel(EDIT)->end == 1); @@ -321,7 +327,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+k should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, 'k'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -329,7 +335,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+k should delete to end of line) { - setup_view(EDIT, "\nABC\n", 2); + setup_view(EDIT, "\nABC\n", CRLF, 2); send_keys(ModCtrl, 'k'); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); @@ -337,7 +343,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+k should delete entire lines contents) { - setup_view(EDIT, "\nABC\n", 1); + setup_view(EDIT, "\nABC\n", CRLF, 1); send_keys(ModCtrl, 'k'); CHECK(getsel(EDIT)->beg == 1); CHECK(getsel(EDIT)->end == 1); @@ -345,7 +351,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+w should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, 'w'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -353,7 +359,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+w should delete previous word) { - setup_view(EDIT, "abc def", 4); + setup_view(EDIT, "abc def", CRLF, 4); send_keys(ModCtrl, 'w'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -361,14 +367,14 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+h should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, 'h'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+h should delete previous character) { - setup_view(EDIT, "AB", 1); + setup_view(EDIT, "AB", CRLF, 1); send_keys(ModCtrl, 'h'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -376,63 +382,63 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+a should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, 'a'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+a should move to beginning of indented content) { - setup_view(EDIT, " ABCD", 7); + setup_view(EDIT, " ABCD", CRLF, 7); send_keys(ModCtrl, 'a'); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(ctrl+a should move to beginning of line if at beginning of indented content) { - setup_view(EDIT, " ABCD", 7); + setup_view(EDIT, " ABCD", CRLF, 7); send_keys(ModCtrl, 'a'); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(ctrl+a should move to beginning of indented content when at beginning of line) { - setup_view(EDIT, " ABCD", 0); + setup_view(EDIT, " ABCD", CRLF, 0); send_keys(ModCtrl, 'a'); CHECK(getsel(EDIT)->beg == 4); CHECK(getsel(EDIT)->end == 4); } TEST(ctrl+e should do nothing for empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, 'e'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } TEST(ctrl+e should do nothing at end of line) { - setup_view(EDIT, "AB\nCD", 2); + setup_view(EDIT, "AB\nCD", CRLF, 2); send_keys(ModCtrl, 'e'); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); } TEST(ctrl+e should move to end of line) { - setup_view(EDIT, "AB\nCD", 0); + setup_view(EDIT, "AB\nCD", CRLF, 0); send_keys(ModCtrl, 'e'); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); } TEST(esc should select previously inserted text) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); send_keys(ModNone, KEY_ESCAPE); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 3); } TEST(esc should select nothing if no previous insert) { - setup_view(EDIT, "foob", 4); + setup_view(EDIT, "foob", CRLF, 4); send_keys(ModNone, KEY_BACKSPACE); send_keys(ModNone, KEY_ESCAPE); CHECK(getsel(EDIT)->beg == 3); @@ -442,7 +448,7 @@ TEST_SUITE(XeditTests) { /* Key Handling - Standard Text Editing Shortcuts *************************************************************************/ TEST(cut and paste should delete selection and transfer it to+from the system clipboard) { - setup_view(EDIT, "foo\nbar\nbaz\n", 0); + setup_view(EDIT, "foo\nbar\nbaz\n", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 8, 0 }; send_keys(ModCtrl, 'x'); getview(EDIT)->selection = (Sel){ 4, 4, 0 }; @@ -454,7 +460,7 @@ TEST_SUITE(XeditTests) { TEST(copy and paste should copy selection and transfer it to+from the system clipboard) { getbuf(EDIT)->crlf = 1; - setup_view(EDIT, "foo\nbar\nbaz\n", 0); + setup_view(EDIT, "foo\nbar\nbaz\n", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 8, 0 }; send_keys(ModCtrl, 'c'); getview(EDIT)->selection = (Sel){ 12, 12, 0 }; @@ -467,28 +473,28 @@ TEST_SUITE(XeditTests) { /* Key Handling - Block Indent *************************************************************************/ TEST(ctrl+[ should do nothing on empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, '['); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } //TEST(ctrl+[ should do nothing on empty buffer) { - // setup_view(EDIT, "a", 0); + // setup_view(EDIT, "a", CRLF, 0); // send_keys(ModCtrl, '['); // CHECK(getsel(EDIT)->beg == 0); // CHECK(getsel(EDIT)->end == 0); //} TEST(ctrl+] should do nothing on empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModCtrl, ']'); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); } //TEST(ctrl+] should indent the current line) { - // setup_view(EDIT, "a", 0); + // setup_view(EDIT, "a", CRLF, 0); // send_keys(ModCtrl, ']'); // CHECK(getsel(EDIT)->beg == 0); // CHECK(getsel(EDIT)->end == 0); @@ -497,7 +503,7 @@ TEST_SUITE(XeditTests) { /* Key Handling - Special *************************************************************************/ TEST(backspace should do nothing on empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_BACKSPACE); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -505,7 +511,7 @@ TEST_SUITE(XeditTests) { } TEST(backspace should do nothing at beginning of buffer) { - setup_view(EDIT, "abc", 0); + setup_view(EDIT, "abc", CRLF, 0); send_keys(ModNone, KEY_BACKSPACE); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -513,7 +519,7 @@ TEST_SUITE(XeditTests) { } TEST(backspace should delete previous character) { - setup_view(EDIT, "abc", 1); + setup_view(EDIT, "abc", CRLF, 1); send_keys(ModNone, KEY_BACKSPACE); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -521,7 +527,7 @@ TEST_SUITE(XeditTests) { } TEST(backspace should delete selection) { - setup_view(EDIT, "abcde", 0); + setup_view(EDIT, "abcde", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 1, .end = 4 }; send_keys(ModNone, KEY_BACKSPACE); CHECK(getsel(EDIT)->beg == 1); @@ -530,7 +536,7 @@ TEST_SUITE(XeditTests) { } TEST(delete should do nothing on empty buffer) { - setup_view(EDIT, "", 0); + setup_view(EDIT, "", CRLF, 0); send_keys(ModNone, KEY_DELETE); CHECK(getsel(EDIT)->beg == 0); CHECK(getsel(EDIT)->end == 0); @@ -538,7 +544,7 @@ TEST_SUITE(XeditTests) { } TEST(delete should do nothing at end of buffer) { - setup_view(EDIT, "abc", 3); + setup_view(EDIT, "abc", CRLF, 3); send_keys(ModNone, KEY_DELETE); CHECK(getsel(EDIT)->beg == 3); CHECK(getsel(EDIT)->end == 3); @@ -546,7 +552,7 @@ TEST_SUITE(XeditTests) { } TEST(delete should delete next character) { - setup_view(EDIT, "abc", 2); + setup_view(EDIT, "abc", CRLF, 2); send_keys(ModNone, KEY_DELETE); CHECK(getsel(EDIT)->beg == 2); CHECK(getsel(EDIT)->end == 2); @@ -554,7 +560,7 @@ TEST_SUITE(XeditTests) { } TEST(delete should delete selection) { - setup_view(EDIT, "abcde", 0); + setup_view(EDIT, "abcde", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 1, .end = 4 }; send_keys(ModNone, KEY_DELETE); CHECK(getsel(EDIT)->beg == 1); @@ -577,8 +583,8 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+q should quit) { - setup_view(TAGS, "", 0); - setup_view(EDIT, "", 0); + setup_view(TAGS, "", CRLF, 0); + setup_view(EDIT, "", CRLF, 0); getbuf(EDIT)->modified = false; ExitCode = 42; send_keys(ModCtrl, 'q'); @@ -587,7 +593,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+f should find next occurrence of selected text) { - setup_view(EDIT, "foobarfoo", 0); + setup_view(EDIT, "foobarfoo", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 3, 0 }; send_keys(ModCtrl, 'f'); CHECK(getview(EDIT)->selection.beg == 6); @@ -595,7 +601,7 @@ TEST_SUITE(XeditTests) { } TEST(ctrl+f should wrap around to beginning of buffer) { - setup_view(EDIT, "foobarbazfoo", 0); + setup_view(EDIT, "foobarbazfoo", CRLF, 0); getview(EDIT)->selection = (Sel){ 9, 12, 0 }; send_keys(ModCtrl, 'f'); CHECK(getview(EDIT)->selection.beg == 0); @@ -608,9 +614,9 @@ TEST_SUITE(XeditTests) { /* Command Execution *************************************************************************/ TEST(Commands starting with : should be executed as sed scripts) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 0, .end = 3 }; - setup_view(TAGS, ":s/foo/bar/", 0); + setup_view(TAGS, ":s/foo/bar/", CRLF, 0); getview(TAGS)->selection = (Sel){ .beg = 0, .end = 11 }; send_keys(ModCtrl, 'd'); #ifdef __MACH__ @@ -621,9 +627,9 @@ TEST_SUITE(XeditTests) { } TEST(Commands starting with | should be take selection as input and replace it with output) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 0, .end = 3 }; - setup_view(TAGS, "|sed -e 's/foo/bar/'", 0); + setup_view(TAGS, "|sed -e 's/foo/bar/'", CRLF, 0); getview(TAGS)->selection = (Sel){ .beg = 0, .end = 20 }; send_keys(ModCtrl, 'd'); #ifdef __MACH__ @@ -634,9 +640,9 @@ TEST_SUITE(XeditTests) { } TEST(Commands starting with ! should execute in the background with no input or output) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 0, .end = 3 }; - setup_view(TAGS, "!ls", 0); + setup_view(TAGS, "!ls", CRLF, 0); getview(TAGS)->selection = (Sel){ .beg = 0, .end = 3 }; send_keys(ModCtrl, 'd'); CHECK(verify_text(EDIT, "foo")); @@ -644,9 +650,9 @@ TEST_SUITE(XeditTests) { #if 0 TEST(Commands starting with > should execute in the background with selection as input) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 0, .end = 3 }; - setup_view(TAGS, ">cat", 0); + setup_view(TAGS, ">cat", CRLF, 0); getview(TAGS)->selection = (Sel){ .beg = 0, .end = 4 }; send_keys(ModCtrl, 'd'); CHECK(verify_text(EDIT, "foo")); @@ -654,16 +660,16 @@ TEST_SUITE(XeditTests) { #endif TEST(Commands starting with < should replace selection with output) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 0, .end = 3 }; - setup_view(TAGS, "selection = (Sel){ .beg = 0, .end = 9 }; send_keys(ModCtrl, 'd'); CHECK(verify_text(EDIT, "bar\r\n")); } TEST(Commands not starting with a sigil should replace themselves with their output) { - setup_view(EDIT, "echo foo", 0); + setup_view(EDIT, "echo foo", CRLF, 0); getview(EDIT)->selection = (Sel){ .beg = 0, .end = 8 }; send_keys(ModCtrl, 'd'); CHECK(verify_text(EDIT, "foo\r\n")); @@ -672,8 +678,8 @@ TEST_SUITE(XeditTests) { /* Tag Handling *************************************************************************/ TEST(Quit should quit immediately if buffer is unmodified) { - setup_view(TAGS, "", 0); - setup_view(EDIT, "", 0); + setup_view(TAGS, "", CRLF, 0); + setup_view(EDIT, "", CRLF, 0); getbuf(EDIT)->modified = false; ExitCode = 42; exec("Quit"); @@ -682,8 +688,8 @@ TEST_SUITE(XeditTests) { } TEST(Quit should display error message when quit called with unsaved changes) { - setup_view(TAGS, "", 0); - setup_view(EDIT, "", 0); + setup_view(TAGS, "", CRLF, 0); + setup_view(EDIT, "", CRLF, 0); getbuf(EDIT)->modified = true; ExitCode = 42; usleep(251 * 1000); @@ -693,8 +699,8 @@ TEST_SUITE(XeditTests) { } TEST(Quit should discard changes if quit executed twice in less than 250 ms) { - setup_view(TAGS, "", 0); - setup_view(EDIT, "", 0); + setup_view(TAGS, "", CRLF, 0); + setup_view(EDIT, "", CRLF, 0); getbuf(EDIT)->modified = true; ExitCode = 42; usleep(251 * 1000); @@ -707,7 +713,7 @@ TEST_SUITE(XeditTests) { } TEST(Save should save changes to disk with crlf line endings) { - setup_view(TAGS, "", 0); + setup_view(TAGS, "", CRLF, 0); view_init(getview(EDIT), "docs/crlf.txt"); CHECK(verify_text(EDIT, "this file\r\nuses\r\ndos\r\nline\r\nendings\r\n")); exec("Save"); @@ -716,7 +722,7 @@ TEST_SUITE(XeditTests) { } TEST(Save should save changes to disk with lf line endings) { - setup_view(TAGS, "", 0); + setup_view(TAGS, "", CRLF, 0); view_init(getview(EDIT), "docs/lf.txt"); CHECK(verify_text(EDIT, "this file\nuses\nunix\nline\nendings\n")); exec("Save"); @@ -725,7 +731,7 @@ TEST_SUITE(XeditTests) { } TEST(Cut and Paste tags should move selection to new location) { - setup_view(EDIT, "foo\nbar\nbaz\n", 0); + setup_view(EDIT, "foo\nbar\nbaz\n", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 8, 0 }; exec("Cut"); getview(EDIT)->selection = (Sel){ 4, 4, 0 }; @@ -736,7 +742,7 @@ TEST_SUITE(XeditTests) { } TEST(Copy and Paste tags should copy selection to new location) { - setup_view(EDIT, "foo\nbar\nbaz\n", 0); + setup_view(EDIT, "foo\nbar\nbaz\n", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 8, 0 }; exec("Copy"); getview(EDIT)->selection = (Sel){ 12, 12, 0 }; @@ -747,7 +753,7 @@ TEST_SUITE(XeditTests) { } TEST(Undo+Redo should undo+redo the previous insert) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); exec("Undo"); CHECK(verify_text(EDIT, "")); exec("Redo"); @@ -755,7 +761,7 @@ TEST_SUITE(XeditTests) { } TEST(Undo+Redo should undo+redo the previous delete) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 3, 0 }; send_keys(ModNone, KEY_DELETE); exec("Undo"); @@ -765,7 +771,7 @@ TEST_SUITE(XeditTests) { } TEST(Undo+Redo should undo+redo the previous delete with two non-contiguous deletes logged) { - setup_view(EDIT, "foobarbaz", 0); + setup_view(EDIT, "foobarbaz", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 3, 0 }; send_keys(ModNone, KEY_DELETE); getview(EDIT)->selection = (Sel){ 3, 6, 0 }; @@ -778,7 +784,7 @@ TEST_SUITE(XeditTests) { } TEST(Undo+Redo should undo+redo the previous delete performed with backspace) { - setup_view(EDIT, "foo", 0); + setup_view(EDIT, "foo", CRLF, 0); getview(EDIT)->selection = (Sel){ 3, 3, 0 }; for(int i = 0; i < 3; i++) send_keys(ModNone, KEY_BACKSPACE); @@ -790,7 +796,7 @@ TEST_SUITE(XeditTests) { } TEST(Find should find next occurrence of text selected in EDIT view) { - setup_view(EDIT, "foobarfoo", 0); + setup_view(EDIT, "foobarfoo", CRLF, 0); getview(EDIT)->selection = (Sel){ 0, 3, 0 }; exec("Find"); CHECK(getview(EDIT)->selection.beg == 6); @@ -798,7 +804,7 @@ TEST_SUITE(XeditTests) { } TEST(Find should find wrap around to beginning of EDIT buffer) { - setup_view(EDIT, "foobarbazfoo", 0); + setup_view(EDIT, "foobarbazfoo", CRLF, 0); getview(EDIT)->selection = (Sel){ 9, 12, 0 }; exec("Find"); CHECK(getview(EDIT)->selection.beg == 0); @@ -806,16 +812,16 @@ TEST_SUITE(XeditTests) { } TEST(Find should find next occurrence of text selected in TAGS view) { - setup_view(TAGS, "foo", 0); + setup_view(TAGS, "foo", CRLF, 0); getview(TAGS)->selection = (Sel){ 0, 3, 0 }; - setup_view(EDIT, "barfoo", 0); + setup_view(EDIT, "barfoo", CRLF, 0); exec("Find"); CHECK(getview(EDIT)->selection.beg == 3); CHECK(getview(EDIT)->selection.end == 6); } TEST(Find should find next occurrence of text selected after tag) { - setup_view(EDIT, "barfoo", 0); + setup_view(EDIT, "barfoo", CRLF, 0); exec("Find foo"); CHECK(getview(EDIT)->selection.beg == 3); CHECK(getview(EDIT)->selection.end == 6); @@ -823,14 +829,14 @@ TEST_SUITE(XeditTests) { #if 0 TEST(Find should do nothing if nothing selected) { - setup_view(TAGS, "Find", 0); + setup_view(TAGS, "Find", CRLF, 0); getview(TAGS)->selection = (Sel){ 0, 4, 0 }; send_keys(ModCtrl, 'f'); } #endif TEST(Tabs should set indent style to tabs) { - setup_view(TAGS, "Tabs", 0); + setup_view(TAGS, "Tabs", CRLF, 0); getview(TAGS)->selection = (Sel){ 0, 4, 0 }; getbuf(EDIT)->expand_tabs = true; getbuf(TAGS)->expand_tabs = true; @@ -840,7 +846,7 @@ TEST_SUITE(XeditTests) { } TEST(Tabs should set indent style to spaces) { - setup_view(TAGS, "Tabs", 0); + setup_view(TAGS, "Tabs", CRLF, 0); getview(TAGS)->selection = (Sel){ 0, 4, 0 }; getbuf(EDIT)->expand_tabs = false; getbuf(TAGS)->expand_tabs = false; @@ -850,7 +856,7 @@ TEST_SUITE(XeditTests) { } TEST(Indent should disable copyindent) { - setup_view(TAGS, "Indent", 0); + setup_view(TAGS, "Indent", CRLF, 0); getview(TAGS)->selection = (Sel){ 0, 6, 0 }; getbuf(EDIT)->copy_indent = true; getbuf(TAGS)->copy_indent = true; @@ -860,7 +866,7 @@ TEST_SUITE(XeditTests) { } TEST(Indent should enable copyindent) { - setup_view(TAGS, "Indent", 0); + setup_view(TAGS, "Indent", CRLF, 0); getview(TAGS)->selection = (Sel){ 0, 6, 0 }; getbuf(EDIT)->copy_indent = false; getbuf(TAGS)->copy_indent = false; -- 2.49.0