13 #define LISTS_EQ(a, b) { \ 14 g_assert_cmpint(g_strv_length((gchar **) (a)), ==, g_strv_length((gchar **) (b))); \ 15 for (int i = 0; i < g_strv_length((a)); i++) { \ 16 g_assert_cmpstr((a)[i], ==, (b)[i]); \ 27 const char *argv[] = {
"-a",
"-b",
"-c",
"-d", NULL };
28 const gchar *expected[] = {
"-a",
"-b",
"-c",
"-d", NULL };
32 g_strfreev(processed);
36 g_strfreev(processed);
41 const char *argv[] = {
"-", NULL };
42 const gchar *expected[] = {
"-", NULL };
46 g_strfreev(processed);
51 const char *argv[] = {
"-a",
"--",
"-bc", NULL };
52 const gchar *expected[] = {
"-a",
"--",
"-bc", NULL };
56 g_strfreev(processed);
61 const char *argv[] = {
"-aX",
"-Fval", NULL };
62 const gchar *expected[] = {
"-a",
"X",
"-F",
"val", NULL };
66 g_strfreev(processed);
70 special_arg_at_end(
void) {
71 const char *argv[] = {
"-a", NULL };
72 const gchar *expected[] = {
"-a", NULL };
76 g_strfreev(processed);
81 const char *argv[] = {
"--blah=foo", NULL };
82 const gchar *expected[] = {
"--blah=foo", NULL };
86 g_strfreev(processed);
90 negative_score(
void) {
91 const char *argv[] = {
"-v",
"-1000", NULL };
92 const gchar *expected[] = {
"-v",
"-1000", NULL };
96 g_strfreev(processed);
100 negative_score_2(
void) {
101 const char *argv[] = {
"-1i3", NULL };
102 const gchar *expected[] = {
"-1",
"-i",
"-3", NULL };
106 g_strfreev(processed);
110 string_arg_with_dash(
void) {
111 const char *argv[] = {
"-n",
"crm_mon_options",
"-v",
"--opt1 --opt2", NULL };
112 const gchar *expected[] = {
"-n",
"crm_mon_options",
"-v",
"--opt1 --opt2", NULL };
116 g_strfreev(processed);
120 string_arg_with_dash_2(
void) {
121 const char *argv[] = {
"-n",
"crm_mon_options",
"-v",
"-1i3", NULL };
122 const gchar *expected[] = {
"-n",
"crm_mon_options",
"-v",
"-1i3", NULL };
126 g_strfreev(processed);
130 string_arg_with_dash_3(
void) {
131 const char *argv[] = {
"-abc",
"-1i3", NULL };
132 const gchar *expected[] = {
"-a",
"-b",
"-c",
"-1i3", NULL };
136 g_strfreev(processed);
142 g_test_init(&argc, &argv, NULL);
144 g_test_add_func(
"/common/cmdline/preproc/empty_input", empty_input);
145 g_test_add_func(
"/common/cmdline/preproc/no_specials", no_specials);
146 g_test_add_func(
"/common/cmdline/preproc/single_dash", single_dash);
147 g_test_add_func(
"/common/cmdline/preproc/double_dash", double_dash);
148 g_test_add_func(
"/common/cmdline/preproc/special_args", special_args);
149 g_test_add_func(
"/common/cmdline/preproc/special_arg_at_end", special_arg_at_end);
150 g_test_add_func(
"/common/cmdline/preproc/long_arg", long_arg);
151 g_test_add_func(
"/common/cmdline/preproc/negative_score", negative_score);
152 g_test_add_func(
"/common/cmdline/preproc/negative_score_2", negative_score_2);
153 g_test_add_func(
"/common/cmdline/preproc/string_arg_with_dash", string_arg_with_dash);
154 g_test_add_func(
"/common/cmdline/preproc/string_arg_with_dash_2", string_arg_with_dash_2);
155 g_test_add_func(
"/common/cmdline/preproc/string_arg_with_dash_3", string_arg_with_dash_3);
gchar ** pcmk__cmdline_preproc(char **argv, const char *special)
int main(int argc, char **argv)