xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 9937cef4dc2ea6fe78492f674fc44a5c9f7c8006

Test that :normal exits command-line
Author: xaizek
Author date (UTC): 2025-07-01 12:03
Committer name: xaizek
Committer date (UTC): 2025-07-01 12:24
Parent(s): 37e743be56309fe42ac4154f4cd26eac1f9f4946
Signing key: 99DC5E4DB05F6BE2
Tree: 709e62159d79a31accf1c8ad21a48b83d665870e
File Lines added Lines deleted
tests/commands/normal.c 27 12
File tests/commands/normal.c changed (mode: 100644) (index a6053dff9..5967b6267)
5 5 #include <test-utils.h> #include <test-utils.h>
6 6
7 7 #include "../../src/engine/keys.h" #include "../../src/engine/keys.h"
8 #include "../../src/engine/mode.h"
8 9 #include "../../src/modes/modes.h" #include "../../src/modes/modes.h"
9 10 #include "../../src/ui/ui.h" #include "../../src/ui/ui.h"
10 11 #include "../../src/utils/dynarray.h" #include "../../src/utils/dynarray.h"
 
... ... SETUP()
18 19 curr_view = &lwin; curr_view = &lwin;
19 20 other_view = &rwin; other_view = &rwin;
20 21
22 lwin.list_rows = 2;
23 lwin.list_pos = 0;
24 lwin.dir_entry = dynarray_cextend(NULL,
25 lwin.list_rows*sizeof(*lwin.dir_entry));
26 lwin.dir_entry[0].name = strdup("a");
27 lwin.dir_entry[0].origin = &lwin.curr_dir[0];
28 lwin.dir_entry[0].selected = 1;
29 lwin.dir_entry[1].name = strdup("b");
30 lwin.dir_entry[1].origin = &lwin.curr_dir[0];
31 lwin.dir_entry[1].selected = 0;
32 lwin.selected_files = 1;
33
21 34 cmds_init(); cmds_init();
22 35 modes_init(); modes_init();
23 36 opt_handlers_setup(); opt_handlers_setup();
 
... ... TEARDOWN()
36 49 opt_handlers_teardown(); opt_handlers_teardown();
37 50 } }
38 51
39 TEST(normal_command_does_not_reset_selection)
52 TEST(normal_command_exits_cmdline_mode)
40 53 { {
41 lwin.list_rows = 2;
42 lwin.list_pos = 0;
43 lwin.dir_entry = dynarray_cextend(NULL,
44 lwin.list_rows*sizeof(*lwin.dir_entry));
45 lwin.dir_entry[0].name = strdup("a");
46 lwin.dir_entry[0].origin = &lwin.curr_dir[0];
47 lwin.dir_entry[0].selected = 1;
48 lwin.dir_entry[1].name = strdup("b");
49 lwin.dir_entry[1].origin = &lwin.curr_dir[0];
50 lwin.dir_entry[1].selected = 0;
51 lwin.selected_files = 1;
54 assert_true(vle_mode_is(NORMAL_MODE));
55
56 assert_success(cmds_dispatch("normal :", &lwin, CIT_COMMAND));
57 assert_true(vle_mode_is(NORMAL_MODE));
52 58
59 assert_success(cmds_dispatch("normal /", &lwin, CIT_COMMAND));
60 assert_true(vle_mode_is(NORMAL_MODE));
61
62 assert_success(cmds_dispatch("normal =", &lwin, CIT_COMMAND));
63 assert_true(vle_mode_is(NORMAL_MODE));
64 }
65
66 TEST(normal_command_does_not_reset_selection)
67 {
53 68 assert_success(cmds_dispatch(":normal! t", &lwin, CIT_COMMAND)); assert_success(cmds_dispatch(":normal! t", &lwin, CIT_COMMAND));
54 69 assert_int_equal(0, lwin.selected_files); assert_int_equal(0, lwin.selected_files);
55 70 assert_false(lwin.dir_entry[0].selected); assert_false(lwin.dir_entry[0].selected);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master