1 #include <stic.h>
2 
3 #include "../../src/engine/keys.h"
4 #include "../../src/engine/mode.h"
5 #include "../../src/modes/modes.h"
6 
7 static int handler(wchar_t key);
8 
9 static int counter;
10 
SETUP()11 SETUP()
12 {
13 	vle_keys_set_def_handler(CMDLINE_MODE, &handler);
14 	vle_keys_user_add(L"s", L":shell", NORMAL_MODE, KEYS_FLAG_NONE);
15 	vle_keys_user_add(L"q", L"toto", CMDLINE_MODE, KEYS_FLAG_NONE);
16 }
17 
TEARDOWN()18 TEARDOWN()
19 {
20 	vle_keys_set_def_handler(CMDLINE_MODE, NULL);
21 	vle_mode_set(NORMAL_MODE, VMT_PRIMARY);
22 }
23 
24 static int
handler(wchar_t key)25 handler(wchar_t key)
26 {
27 	static const wchar_t line[] = L"shelltoto";
28 
29 	char exp[] = {line[counter++], '\0'};
30 	char act[] = {key, '\0'};
31 
32 	assert_string_equal(exp, act);
33 	return 0;
34 }
35 
TEST(cmd_line)36 TEST(cmd_line)
37 {
38 	counter = 0;
39 
40 	assert_false(IS_KEYS_RET_CODE(vle_keys_exec(L"s")));
41 	assert_false(IS_KEYS_RET_CODE(vle_keys_exec(L"q")));
42 
43 	assert_true(counter == 9);
44 }
45 
46 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0: */
47 /* vim: set cinoptions+=t0 filetype=c : */
48