summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdvik/tests/test_util.c
blob: 239927190c817c96b93a855c166df87687188e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "run_tests.h"
#include "util.h"
#include "string-utils.h"

static Boolean
test_src_format_arguments(int verbose)
{
    static struct stringtest {
	char *str;
	char *res[16]; /* big enuff */
    } tests[] = {
	{ "emacsclient --no-wait +%l %f",
	  { "emacsclient", "--no-wait", "+10", "/this/is/a/filename.tex", NULL }
	},
	{ "vim +%l:%c %f",
	  { "vim", "+10:0", "/this/is/a/filename.tex", NULL }
	},
	{ "bazoo %f:%l:%c",
	  { "bazoo", "/this/is/a/filename.tex:10:0", NULL }
	}
    };

    const char *filename = "/this/is/a/filename.tex";
    int lineno = 10;
    int colno = 0;
    size_t i;
    Boolean res = True;
    
    for (i = 0; i < (sizeof tests / sizeof tests[0]); i++) {
	char **argv = get_separated_list(tests[i].str, " \t", True);
	argv = src_format_arguments(argv, filename, lineno, colno);
	if (!test_str_list_equality(verbose, argv, tests[i].res)) {
	    res = False;
	}
    }

    return res;
}


void
register_all_from_test_util(void)
{
    register_test(test_src_format_arguments, "src_format_arguments");
}