add test for keybind parser function
This commit is contained in:
parent
4c17699c14
commit
f7534a551e
37
src/tests.c
37
src/tests.c
@ -1,3 +1,4 @@
|
||||
#include <X11/X.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
@ -10,6 +11,7 @@
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <json-c/json_tokener.h>
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "client.h"
|
||||
#include "wm.h"
|
||||
@ -517,6 +519,40 @@ static void test_wm_logentries_calculate_distances(void **state)
|
||||
wm_treenode_free(child);
|
||||
}
|
||||
|
||||
static void test_wm_keybind_str_to_mask_keysym(void **state)
|
||||
{
|
||||
char *keybind1 = "Windows+Shift+h";
|
||||
char *keybind2 = "Alt+1";
|
||||
char *keybind3 = "Windows+Alt+Shift+j";
|
||||
char *keybind4 = "CapsLock+k";
|
||||
|
||||
KeySym *ret;
|
||||
|
||||
ret = wm_keybind_str_to_mask_keysym(keybind1);
|
||||
assert_int_equal(ret[0], Mod4Mask | ShiftMask);
|
||||
assert_int_equal(ret[1], XK_h);
|
||||
|
||||
free(ret);
|
||||
|
||||
ret = wm_keybind_str_to_mask_keysym(keybind2);
|
||||
assert_int_equal(ret[0], Mod1Mask);
|
||||
assert_int_equal(ret[1], XK_1);
|
||||
|
||||
free(ret);
|
||||
|
||||
ret = wm_keybind_str_to_mask_keysym(keybind3);
|
||||
assert_int_equal(ret[0], Mod4Mask | Mod1Mask | ShiftMask);
|
||||
assert_int_equal(ret[1], XK_j);
|
||||
|
||||
free(ret);
|
||||
|
||||
ret = wm_keybind_str_to_mask_keysym(keybind4);
|
||||
assert_int_equal(ret[0], LockMask);
|
||||
assert_int_equal(ret[1], XK_k);
|
||||
|
||||
free(ret);
|
||||
}
|
||||
|
||||
static void test_wm_postorder_traversal(void **state)
|
||||
{
|
||||
TreeNode *node1 = (TreeNode*)*state;
|
||||
@ -1022,6 +1058,7 @@ int main(void)
|
||||
cmocka_unit_test(test_wm_json_obj_to_treenode),
|
||||
cmocka_unit_test(test_wm_read_log),
|
||||
cmocka_unit_test(test_wm_logentries_calculate_distances),
|
||||
cmocka_unit_test(test_wm_keybind_str_to_mask_keysym),
|
||||
};
|
||||
|
||||
const struct CMUnitTest test_group2[] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user