Debian Codegraph @

texk/xdvik/tests/test_util.c

raw
1 #include "run_tests.h"
2 #include "util.h"
3 #include "string-utils.h"
4
5 static Boolean
6 test_src_format_arguments(int verbose)
7 {
8 static struct stringtest {
9 char *str;
10 char *res[16]; /* big enuff */
11 } tests[] = {
12 { "emacsclient --no-wait +%l %f",
13 { "emacsclient", "--no-wait", "+10", "/this/is/a/filename.tex", NULL }
14 },
15 { "vim +%l:%c %f",
16 { "vim", "+10:0", "/this/is/a/filename.tex", NULL }
17 },
18 { "bazoo %f:%l:%c",
19 { "bazoo", "/this/is/a/filename.tex:10:0", NULL }
20 }
21 };
22
23 const char *filename = "/this/is/a/filename.tex";
24 int lineno = 10;
25 int colno = 0;
26 size_t i;
27 Boolean res = True;
28
29 for (i = 0; i < (sizeof tests / sizeof tests[0]); i++) {
30 char **argv = get_separated_list(tests[i].str, " \t", True);
31 argv = src_format_arguments(argv, filename, lineno, colno);
32 if (!test_str_list_equality(verbose, argv, tests[i].res)) {
33 res = False;
34 }
35 }
36
37 return res;
38 }
39
40
41 void
42 register_all_from_test_util(void)
43 {
44 register_test(test_src_format_arguments, "src_format_arguments");
45 }