summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-02-03 22:50:32 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-02-03 22:50:32 +0100
commit1f073fe9490d70ab9ae5308c60e52ef2f74748c9 (patch)
tree868cf6712258aa76881e3d86941f21e4611bd009 /tests/unit
parent68a5a71b55575cdd745b48202686f8c83921735f (diff)
downloadweechat-1f073fe9490d70ab9ae5308c60e52ef2f74748c9.zip
tests: add tests on function gui_key_cmp
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/gui/test-gui-key.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/unit/gui/test-gui-key.cpp b/tests/unit/gui/test-gui-key.cpp
index 497d999d5..e0ddc9d64 100644
--- a/tests/unit/gui/test-gui-key.cpp
+++ b/tests/unit/gui/test-gui-key.cpp
@@ -26,6 +26,8 @@
extern "C"
{
#include "src/gui/gui-key.h"
+
+extern int gui_key_cmp (const char *key, const char *search, int context);
}
TEST_GROUP(GuiKey)
@@ -233,7 +235,43 @@ TEST(GuiKey, Search)
TEST(GuiKey, Cmp)
{
- /* TODO: write tests */
+ LONGS_EQUAL(0, gui_key_cmp ("", "", GUI_KEY_CONTEXT_DEFAULT));
+ LONGS_EQUAL(0, gui_key_cmp ("a", "", GUI_KEY_CONTEXT_DEFAULT));
+ LONGS_EQUAL(-97, gui_key_cmp ("", "a", GUI_KEY_CONTEXT_DEFAULT));
+ LONGS_EQUAL(0, gui_key_cmp ("a", "a", GUI_KEY_CONTEXT_DEFAULT));
+ LONGS_EQUAL(32, gui_key_cmp ("meta-a", "meta-A", GUI_KEY_CONTEXT_DEFAULT));
+ LONGS_EQUAL(-99, gui_key_cmp ("meta-a", "meta-ac", GUI_KEY_CONTEXT_DEFAULT));
+ LONGS_EQUAL(0, gui_key_cmp ("meta-ac", "meta-a", GUI_KEY_CONTEXT_DEFAULT));
+
+ LONGS_EQUAL(0, gui_key_cmp ("", "", GUI_KEY_CONTEXT_SEARCH));
+ LONGS_EQUAL(0, gui_key_cmp ("a", "", GUI_KEY_CONTEXT_SEARCH));
+ LONGS_EQUAL(-97, gui_key_cmp ("", "a", GUI_KEY_CONTEXT_SEARCH));
+ LONGS_EQUAL(0, gui_key_cmp ("a", "a", GUI_KEY_CONTEXT_SEARCH));
+ LONGS_EQUAL(32, gui_key_cmp ("meta-a", "meta-A", GUI_KEY_CONTEXT_SEARCH));
+ LONGS_EQUAL(-99, gui_key_cmp ("meta-a", "meta-ac", GUI_KEY_CONTEXT_SEARCH));
+ LONGS_EQUAL(0, gui_key_cmp ("meta-ac", "meta-a", GUI_KEY_CONTEXT_SEARCH));
+
+ LONGS_EQUAL(0, gui_key_cmp ("", "", GUI_KEY_CONTEXT_CURSOR));
+ LONGS_EQUAL(0, gui_key_cmp ("a", "", GUI_KEY_CONTEXT_CURSOR));
+ LONGS_EQUAL(-97, gui_key_cmp ("", "a", GUI_KEY_CONTEXT_CURSOR));
+ LONGS_EQUAL(0, gui_key_cmp ("a", "a", GUI_KEY_CONTEXT_CURSOR));
+ LONGS_EQUAL(32, gui_key_cmp ("meta-a", "meta-A", GUI_KEY_CONTEXT_CURSOR));
+ LONGS_EQUAL(-99, gui_key_cmp ("meta-a", "meta-ac", GUI_KEY_CONTEXT_CURSOR));
+ LONGS_EQUAL(0, gui_key_cmp ("meta-ac", "meta-a", GUI_KEY_CONTEXT_CURSOR));
+
+ LONGS_EQUAL(1, gui_key_cmp ("", "", GUI_KEY_CONTEXT_MOUSE));
+ LONGS_EQUAL(1, gui_key_cmp ("a", "", GUI_KEY_CONTEXT_MOUSE));
+ LONGS_EQUAL(1, gui_key_cmp ("", "a", GUI_KEY_CONTEXT_MOUSE));
+ LONGS_EQUAL(0, gui_key_cmp ("a", "a", GUI_KEY_CONTEXT_MOUSE));
+ LONGS_EQUAL(0, gui_key_cmp ("@chat(fset.fset):button2",
+ "@chat(fset.fset):button2",
+ GUI_KEY_CONTEXT_MOUSE));
+ LONGS_EQUAL(0, gui_key_cmp ("@chat(fset.fset):button2-gesture-right",
+ "@chat(fset.fset):button2*",
+ GUI_KEY_CONTEXT_MOUSE));
+ LONGS_EQUAL(1, gui_key_cmp ("@chat(Fset.fset):button2-gesture-right",
+ "@chat(fset.fset):button2*",
+ GUI_KEY_CONTEXT_MOUSE));
}
/*