File tests/commands/goto.c added (mode: 100644) (index 000000000..93f29076d) |
|
1 |
|
#include <stic.h> |
|
2 |
|
|
|
3 |
|
#include <stdio.h> /* snprintf() */ |
|
4 |
|
|
|
5 |
|
#include <test-utils.h> |
|
6 |
|
|
|
7 |
|
#include "../../src/compat/fs_limits.h" |
|
8 |
|
#include "../../src/ui/ui.h" |
|
9 |
|
#include "../../src/utils/fs.h" |
|
10 |
|
#include "../../src/cmd_core.h" |
|
11 |
|
#include "../../src/filelist.h" |
|
12 |
|
|
|
13 |
|
static char test_data[PATH_MAX + 1]; |
|
14 |
|
|
|
15 |
|
SETUP_ONCE() |
|
16 |
|
{ |
|
17 |
|
make_abs_path(test_data, sizeof(test_data), TEST_DATA_PATH, "", NULL); |
|
18 |
|
} |
|
19 |
|
|
|
20 |
|
SETUP() |
|
21 |
|
{ |
|
22 |
|
view_setup(&lwin); |
|
23 |
|
view_setup(&rwin); |
|
24 |
|
|
|
25 |
|
curr_view = &lwin; |
|
26 |
|
other_view = &rwin; |
|
27 |
|
|
|
28 |
|
conf_setup(); |
|
29 |
|
undo_setup(); |
|
30 |
|
cmds_init(); |
|
31 |
|
} |
|
32 |
|
|
|
33 |
|
TEARDOWN() |
|
34 |
|
{ |
|
35 |
|
view_teardown(&lwin); |
|
36 |
|
view_teardown(&rwin); |
|
37 |
|
|
|
38 |
|
conf_teardown(); |
|
39 |
|
vle_cmds_reset(); |
|
40 |
|
undo_teardown(); |
|
41 |
|
} |
|
42 |
|
|
|
43 |
|
TEST(goto_navigates) |
|
44 |
|
{ |
|
45 |
|
assert_failure(cmds_dispatch("goto /", &lwin, CIT_COMMAND)); |
|
46 |
|
assert_failure(cmds_dispatch("goto /no-such-path", &lwin, CIT_COMMAND)); |
|
47 |
|
|
|
48 |
|
char cmd[PATH_MAX*2]; |
|
49 |
|
snprintf(cmd, sizeof(cmd), "goto %s/compare", test_data); |
|
50 |
|
assert_success(cmds_dispatch(cmd, &lwin, CIT_COMMAND)); |
|
51 |
|
assert_true(paths_are_same(lwin.curr_dir, test_data)); |
|
52 |
|
assert_string_equal("compare", get_current_file_name(&lwin)); |
|
53 |
|
|
|
54 |
|
assert_success(cmds_dispatch("goto tree", &lwin, CIT_COMMAND)); |
|
55 |
|
assert_true(paths_are_same(lwin.curr_dir, test_data)); |
|
56 |
|
assert_string_equal("tree", get_current_file_name(&lwin)); |
|
57 |
|
} |
|
58 |
|
|
|
59 |
|
TEST(goto_normalizes_slashes, IF(windows)) |
|
60 |
|
{ |
|
61 |
|
char cmd[PATH_MAX*2]; |
|
62 |
|
snprintf(cmd, sizeof(cmd), "goto %s\\\\compare", test_data); |
|
63 |
|
assert_success(cmds_dispatch(cmd, &lwin, CIT_COMMAND)); |
|
64 |
|
assert_true(paths_are_same(lwin.curr_dir, test_data)); |
|
65 |
|
assert_string_equal("compare", get_current_file_name(&lwin)); |
|
66 |
|
} |
|
67 |
|
|
|
68 |
|
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
|
69 |
|
/* vim: set cinoptions+=t0 filetype=c : */ |
File tests/commands/misc.c changed (mode: 100644) (index 31410be78..4e20417a8) |
3 |
3 |
#include <unistd.h> /* chdir() rmdir() unlink() */ |
#include <unistd.h> /* chdir() rmdir() unlink() */ |
4 |
4 |
|
|
5 |
5 |
#include <limits.h> /* INT_MAX */ |
#include <limits.h> /* INT_MAX */ |
6 |
|
#include <stdio.h> /* remove() */ |
|
|
6 |
|
#include <stdio.h> /* remove() snprintf() */ |
7 |
7 |
#include <string.h> /* strcpy() strdup() */ |
#include <string.h> /* strcpy() strdup() */ |
8 |
8 |
|
|
9 |
9 |
#include <test-utils.h> |
#include <test-utils.h> |
|
... |
... |
TEST(keepsel_preserves_selection) |
478 |
478 |
assert_true(lwin.dir_entry[0].selected); |
assert_true(lwin.dir_entry[0].selected); |
479 |
479 |
} |
} |
480 |
480 |
|
|
481 |
|
TEST(goto_command) |
|
482 |
|
{ |
|
483 |
|
assert_failure(cmds_dispatch("goto /", &lwin, CIT_COMMAND)); |
|
484 |
|
assert_failure(cmds_dispatch("goto /no-such-path", &lwin, CIT_COMMAND)); |
|
485 |
|
|
|
486 |
|
char cmd[PATH_MAX*2]; |
|
487 |
|
snprintf(cmd, sizeof(cmd), "goto %s/compare", test_data); |
|
488 |
|
assert_success(cmds_dispatch(cmd, &lwin, CIT_COMMAND)); |
|
489 |
|
assert_true(paths_are_same(lwin.curr_dir, test_data)); |
|
490 |
|
assert_string_equal("compare", get_current_file_name(&lwin)); |
|
491 |
|
|
|
492 |
|
assert_success(cmds_dispatch("goto tree", &lwin, CIT_COMMAND)); |
|
493 |
|
assert_true(paths_are_same(lwin.curr_dir, test_data)); |
|
494 |
|
assert_string_equal("tree", get_current_file_name(&lwin)); |
|
495 |
|
} |
|
496 |
|
|
|
497 |
|
TEST(goto_normalizes_slashes, IF(windows)) |
|
498 |
|
{ |
|
499 |
|
char cmd[PATH_MAX*2]; |
|
500 |
|
snprintf(cmd, sizeof(cmd), "goto %s\\\\compare", test_data); |
|
501 |
|
assert_success(cmds_dispatch(cmd, &lwin, CIT_COMMAND)); |
|
502 |
|
assert_true(paths_are_same(lwin.curr_dir, test_data)); |
|
503 |
|
assert_string_equal("compare", get_current_file_name(&lwin)); |
|
504 |
|
} |
|
505 |
|
|
|
506 |
481 |
TEST(echo_reports_all_errors) |
TEST(echo_reports_all_errors) |
507 |
482 |
{ |
{ |
508 |
483 |
const char *expected; |
const char *expected; |