diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-12-17 16:59:04 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-12-18 14:13:14 +0100 |
commit | 99c453ee23b69f80b423be1956255fa6567875e8 (patch) | |
tree | 56e1c1af2df6f0e70c13dd9a2297987c2fa050fd | |
parent | d2f447dafcec35fc6eee9835661785682305552c (diff) | |
download | weechat-99c453ee23b69f80b423be1956255fa6567875e8.zip |
tests: add tests on gui delete previous/next char functions
-rw-r--r-- | tests/unit/gui/test-gui-input.cpp | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/tests/unit/gui/test-gui-input.cpp b/tests/unit/gui/test-gui-input.cpp index 2a33d7f55..aa6e8e880 100644 --- a/tests/unit/gui/test-gui-input.cpp +++ b/tests/unit/gui/test-gui-input.cpp @@ -331,7 +331,46 @@ TEST(GuiInput, SearchStop) TEST(GuiInput, DeletePreviousChar) { - /* 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_previous_char (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_previous_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("abc", gui_buffers->input_buffer); + + gui_input_replace_input (gui_buffers, "abc"); + gui_input_set_pos (gui_buffers, 1); + gui_input_delete_previous_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("bc", gui_buffers->input_buffer); + + gui_input_replace_input (gui_buffers, "abc"); + gui_input_set_pos (gui_buffers, 2); + gui_input_delete_previous_char (gui_buffers); + LONGS_EQUAL(1, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("ac", gui_buffers->input_buffer); + + gui_input_replace_input (gui_buffers, "abc"); + gui_input_set_pos (gui_buffers, 3); + gui_input_delete_previous_char (gui_buffers); + LONGS_EQUAL(2, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("ab", gui_buffers->input_buffer); + gui_input_delete_previous_char (gui_buffers); + LONGS_EQUAL(1, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("a", gui_buffers->input_buffer); + gui_input_delete_previous_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("", gui_buffers->input_buffer); + gui_input_delete_previous_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("", gui_buffers->input_buffer); } /* @@ -341,7 +380,46 @@ TEST(GuiInput, DeletePreviousChar) TEST(GuiInput, DeleteNextChar) { - /* 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_char (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, 3); + gui_input_delete_next_char (gui_buffers); + LONGS_EQUAL(3, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("abc", gui_buffers->input_buffer); + + gui_input_replace_input (gui_buffers, "abc"); + gui_input_set_pos (gui_buffers, 2); + gui_input_delete_next_char (gui_buffers); + LONGS_EQUAL(2, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("ab", gui_buffers->input_buffer); + + gui_input_replace_input (gui_buffers, "abc"); + gui_input_set_pos (gui_buffers, 1); + gui_input_delete_next_char (gui_buffers); + LONGS_EQUAL(1, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("ac", gui_buffers->input_buffer); + + gui_input_replace_input (gui_buffers, "abc"); + gui_input_set_pos (gui_buffers, 0); + gui_input_delete_next_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("bc", gui_buffers->input_buffer); + gui_input_delete_next_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("c", gui_buffers->input_buffer); + gui_input_delete_next_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("", gui_buffers->input_buffer); + gui_input_delete_next_char (gui_buffers); + LONGS_EQUAL(0, gui_buffers->input_buffer_pos); + STRCMP_EQUAL("", gui_buffers->input_buffer); } /* |