]> jfr.im git - irc/weechat/weechat.git/commitdiff
tests: add tests on function gui_input_delete_next_word
authorSébastien Helleu <redacted>
Sat, 17 Dec 2022 16:37:02 +0000 (17:37 +0100)
committerSébastien Helleu <redacted>
Sun, 18 Dec 2022 13:13:14 +0000 (14:13 +0100)
tests/unit/gui/test-gui-input.cpp

index a73ef92a8271a603c6d9cf8185e7a3e1ad6ec96a..2476baf7d80aaa37a39072d9033ac5a14eafb9cb 100644 (file)
@@ -574,7 +574,52 @@ TEST(GuiInput, DeletePreviousWordWhitespace)
 
 TEST(GuiInput, DeleteNextWord)
 {
-    /* TODO: write tests */
+    gui_input_replace_input (gui_buffers, "");
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("", gui_buffers->input_buffer);
+
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("", gui_buffers->input_buffer);
+
+    gui_input_replace_input (gui_buffers, "abc");
+    gui_input_set_pos (gui_buffers, 0);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("", gui_buffers->input_buffer);
+
+    gui_input_replace_input (gui_buffers, "abc");
+    gui_input_set_pos (gui_buffers, 1);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(1, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("a", gui_buffers->input_buffer);
+
+    gui_input_replace_input (gui_buffers, "  abc");
+    gui_input_set_pos (gui_buffers, 0);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("", gui_buffers->input_buffer);
+
+    gui_input_replace_input (gui_buffers, "abc def");
+    gui_input_set_pos (gui_buffers, 0);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL(" def", gui_buffers->input_buffer);
+
+    gui_input_replace_input (gui_buffers, "abc def/ghi/jkl");
+    gui_input_set_pos (gui_buffers, 0);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL(" def/ghi/jkl", gui_buffers->input_buffer);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("/ghi/jkl", gui_buffers->input_buffer);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("/jkl", gui_buffers->input_buffer);
+    gui_input_delete_next_word (gui_buffers);
+    LONGS_EQUAL(0, gui_buffers->input_buffer_pos);
+    STRCMP_EQUAL("", gui_buffers->input_buffer);
 }
 
 /*