Fix mu_parseopt. Add testsuite for it.
* include/mailutils/opt.h (mu_parseopt) <po_permuted>: New member. * libmailutils/opt/help.c (print_option): Fix display of optional arguments. * libmailutils/opt/opt.c (next_opt,parse): Fix start-of-arguments index. Move permutation into a separate function. * libmailutils/opt/progname.c (mu_set_progname): Remove eventual lt- prefix. * libmailutils/tests/Makefile.am: Add new tests. * libmailutils/tests/parseopt.c: Use environment to control mu_parseopt flags. * libmailutils/tests/testsuite.at: Add new tests. * libmailutils/tests/strtoc.at: Update. * libmailutils/tests/parseopt00.at: New file. * libmailutils/tests/parseopt01.at: New file. * libmailutils/tests/parseopt02.at: New file. * libmailutils/tests/parseopt03.at: New file. * libmailutils/tests/parseopt04.at: New file. * libmailutils/tests/parseopt05.at: New file. * libmailutils/tests/parseopt06.at: New file. * libmailutils/tests/parseopt07.at: New file. * libmailutils/tests/parseopt08.at: New file. * libmailutils/tests/parseopt09.at: New file. * libmailutils/tests/parseopt10.at: New file. * libmailutils/tests/parseopt11.at: New file. * libmailutils/tests/parseopt12.at: New file. * libmailutils/tests/parseopt13.at: New file. * libmailutils/tests/parseopt14.at: New file. * libmailutils/tests/parseopt15.at: New file. * libmailutils/tests/parseopt16.at: New file. * libmailutils/tests/parseopt17.at: New file. * libmailutils/tests/parseopt18.at: New file. * libmailutils/tests/parseopt19.at: New file. * libmailutils/tests/parseopt20.at: New file. * libmailutils/tests/parseopt21.at: New file. * libmailutils/tests/parseopt22.at: New file.
Showing
31 changed files
with
925 additions
and
34 deletions
... | @@ -149,6 +149,7 @@ struct mu_parseopt | ... | @@ -149,6 +149,7 @@ struct mu_parseopt |
149 | int po_arg_start; | 149 | int po_arg_start; |
150 | int po_arg_count; | 150 | int po_arg_count; |
151 | 151 | ||
152 | unsigned po_permuted:1; /* Whether the arguments were permuted */ | ||
152 | }; | 153 | }; |
153 | 154 | ||
154 | int mu_parseopt (struct mu_parseopt *p, | 155 | int mu_parseopt (struct mu_parseopt *p, | ... | ... |
... | @@ -132,6 +132,14 @@ print_option (struct mu_option **optbuf, size_t optcnt, size_t num, | ... | @@ -132,6 +132,14 @@ print_option (struct mu_option **optbuf, size_t optcnt, size_t num, |
132 | if (opt->opt_arg) | 132 | if (opt->opt_arg) |
133 | { | 133 | { |
134 | *argsused = 1; | 134 | *argsused = 1; |
135 | if (opt->opt_flags & MU_OPTION_ARG_OPTIONAL) | ||
136 | { | ||
137 | if (delim == '=') | ||
138 | w += printf ("[=%s]", gettext (opt->opt_arg)); | ||
139 | else | ||
140 | w += printf ("[%s]", gettext (opt->opt_arg)); | ||
141 | } | ||
142 | else | ||
135 | w += printf ("%c%s", delim, gettext (opt->opt_arg)); | 143 | w += printf ("%c%s", delim, gettext (opt->opt_arg)); |
136 | } | 144 | } |
137 | if (w >= DESCRCOLUMN) | 145 | if (w >= DESCRCOLUMN) | ... | ... |
... | @@ -228,25 +228,9 @@ find_long_option (struct mu_parseopt *po, char const *optstr, | ... | @@ -228,25 +228,9 @@ find_long_option (struct mu_parseopt *po, char const *optstr, |
228 | return NULL; | 228 | return NULL; |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | static void | |
232 | /* Consume next option from PO. On success, update PO members as | 232 | permute (struct mu_parseopt *po) |
233 | described below and return 0. On end of options, return 1. | ||
234 | |||
235 | If the consumed option is a short option, then | ||
236 | |||
237 | po_chr keeps its option character, and | ||
238 | po_cur points to the next option character to be processed | ||
239 | |||
240 | Otherwise, if the consumed option is a long one, then | ||
241 | |||
242 | po_chr is 0 | ||
243 | po_cur points to the first character after -- | ||
244 | */ | ||
245 | static int | ||
246 | next_opt (struct mu_parseopt *po) | ||
247 | { | 233 | { |
248 | if (!*po->po_cur) | ||
249 | { | ||
250 | if (!(po->po_flags & MU_PARSEOPT_IN_ORDER) && po->po_arg_count) | 234 | if (!(po->po_flags & MU_PARSEOPT_IN_ORDER) && po->po_arg_count) |
251 | { | 235 | { |
252 | /* Array to save arguments in */ | 236 | /* Array to save arguments in */ |
... | @@ -274,10 +258,29 @@ next_opt (struct mu_parseopt *po) | ... | @@ -274,10 +258,29 @@ next_opt (struct mu_parseopt *po) |
274 | 258 | ||
275 | /* Fix up start index */ | 259 | /* Fix up start index */ |
276 | po->po_arg_start += n; | 260 | po->po_arg_start += n; |
261 | po->po_permuted = 1; | ||
277 | } | 262 | } |
263 | } | ||
278 | 264 | ||
279 | if (po->po_ind == po->po_argc) | 265 | /* Consume next option from PO. On success, update PO members as |
280 | return 1; | 266 | described below and return 0. On end of options, return 1. |
267 | |||
268 | If the consumed option is a short option, then | ||
269 | |||
270 | po_chr keeps its option character, and | ||
271 | po_cur points to the next option character to be processed | ||
272 | |||
273 | Otherwise, if the consumed option is a long one, then | ||
274 | |||
275 | po_chr is 0 | ||
276 | po_cur points to the first character after -- | ||
277 | */ | ||
278 | static int | ||
279 | next_opt (struct mu_parseopt *po) | ||
280 | { | ||
281 | if (!*po->po_cur) | ||
282 | { | ||
283 | permute (po); | ||
281 | 284 | ||
282 | while (1) | 285 | while (1) |
283 | { | 286 | { |
... | @@ -288,6 +291,8 @@ next_opt (struct mu_parseopt *po) | ... | @@ -288,6 +291,8 @@ next_opt (struct mu_parseopt *po) |
288 | break; | 291 | break; |
289 | if (!(po->po_flags & MU_PARSEOPT_IN_ORDER)) | 292 | if (!(po->po_flags & MU_PARSEOPT_IN_ORDER)) |
290 | { | 293 | { |
294 | if (!po->po_permuted) | ||
295 | po->po_arg_start = po->po_ind - 1; | ||
291 | po->po_arg_count++; | 296 | po->po_arg_count++; |
292 | continue; | 297 | continue; |
293 | } | 298 | } |
... | @@ -298,8 +303,12 @@ next_opt (struct mu_parseopt *po) | ... | @@ -298,8 +303,12 @@ next_opt (struct mu_parseopt *po) |
298 | if (*++po->po_cur == '-') | 303 | if (*++po->po_cur == '-') |
299 | { | 304 | { |
300 | if (*++po->po_cur == 0) | 305 | if (*++po->po_cur == 0) |
306 | { | ||
301 | /* End of options */ | 307 | /* End of options */ |
308 | permute (po); | ||
309 | ++po->po_ind; | ||
302 | return 1; | 310 | return 1; |
311 | } | ||
303 | 312 | ||
304 | /* It's a long option */ | 313 | /* It's a long option */ |
305 | po->po_chr = 0; | 314 | po->po_chr = 0; |
... | @@ -331,9 +340,12 @@ parse (struct mu_parseopt *po) | ... | @@ -331,9 +340,12 @@ parse (struct mu_parseopt *po) |
331 | { | 340 | { |
332 | char *p = strrchr (po->po_argv[0], '/'); | 341 | char *p = strrchr (po->po_argv[0], '/'); |
333 | if (p) | 342 | if (p) |
334 | po->po_prog_name = p + 1; | 343 | p++; |
335 | else | 344 | else |
336 | po->po_prog_name = (char*) po->po_argv[0]; | 345 | p = (char*) po->po_argv[0]; |
346 | if (strlen (p) > 3 && memcmp (p, "lt-", 3) == 0) | ||
347 | p += 3; | ||
348 | po->po_prog_name = p; | ||
337 | } | 349 | } |
338 | } | 350 | } |
339 | else if (!(po->po_flags & MU_PARSEOPT_PROG_NAME)) | 351 | else if (!(po->po_flags & MU_PARSEOPT_PROG_NAME)) |
... | @@ -341,6 +353,7 @@ parse (struct mu_parseopt *po) | ... | @@ -341,6 +353,7 @@ parse (struct mu_parseopt *po) |
341 | 353 | ||
342 | po->po_arg_start = po->po_ind; | 354 | po->po_arg_start = po->po_ind; |
343 | po->po_arg_count = 0; | 355 | po->po_arg_count = 0; |
356 | po->po_permuted = 0; | ||
344 | 357 | ||
345 | po->po_cur = ""; | 358 | po->po_cur = ""; |
346 | 359 | ||
... | @@ -433,8 +446,8 @@ parse (struct mu_parseopt *po) | ... | @@ -433,8 +446,8 @@ parse (struct mu_parseopt *po) |
433 | } | 446 | } |
434 | } | 447 | } |
435 | 448 | ||
436 | if (po->po_arg_count) | 449 | if (!po->po_permuted) |
437 | po->po_ind = po->po_arg_start; | 450 | po->po_arg_start = po->po_ind - 1 - po->po_arg_count; |
438 | return 0; | 451 | return 0; |
439 | } | 452 | } |
440 | 453 | ... | ... |
... | @@ -38,6 +38,8 @@ mu_set_progname (char const *arg) | ... | @@ -38,6 +38,8 @@ mu_set_progname (char const *arg) |
38 | ++p; | 38 | ++p; |
39 | else | 39 | else |
40 | p = (char*) arg; | 40 | p = (char*) arg; |
41 | if (strlen (p) > 3 && memcmp (p, "lt-", 3) == 0) | ||
42 | p += 3; | ||
41 | free (mu_progname); | 43 | free (mu_progname); |
42 | mu_progname = mu_strdup (p); | 44 | mu_progname = mu_strdup (p); |
43 | } | 45 | } | ... | ... |
... | @@ -104,6 +104,29 @@ TESTSUITE_AT = \ | ... | @@ -104,6 +104,29 @@ TESTSUITE_AT = \ |
104 | modmesg03.at\ | 104 | modmesg03.at\ |
105 | modtofsaf.at\ | 105 | modtofsaf.at\ |
106 | msgset.at\ | 106 | msgset.at\ |
107 | parseopt00.at\ | ||
108 | parseopt01.at\ | ||
109 | parseopt02.at\ | ||
110 | parseopt03.at\ | ||
111 | parseopt04.at\ | ||
112 | parseopt05.at\ | ||
113 | parseopt06.at\ | ||
114 | parseopt07.at\ | ||
115 | parseopt08.at\ | ||
116 | parseopt09.at\ | ||
117 | parseopt10.at\ | ||
118 | parseopt11.at\ | ||
119 | parseopt12.at\ | ||
120 | parseopt13.at\ | ||
121 | parseopt14.at\ | ||
122 | parseopt15.at\ | ||
123 | parseopt16.at\ | ||
124 | parseopt17.at\ | ||
125 | parseopt18.at\ | ||
126 | parseopt19.at\ | ||
127 | parseopt20.at\ | ||
128 | parseopt21.at\ | ||
129 | parseopt22.at\ | ||
107 | prop.at\ | 130 | prop.at\ |
108 | scantime.at\ | 131 | scantime.at\ |
109 | strftime.at\ | 132 | strftime.at\ | ... | ... |
... | @@ -21,8 +21,8 @@ | ... | @@ -21,8 +21,8 @@ |
21 | #include <mailutils/opt.h> | 21 | #include <mailutils/opt.h> |
22 | 22 | ||
23 | char *file_name; | 23 | char *file_name; |
24 | char *find_value; | ||
25 | char *opt_value = "initial"; | 24 | char *opt_value = "initial"; |
25 | char *find_value; | ||
26 | int jobs = 0; | 26 | int jobs = 0; |
27 | int x_option; | 27 | int x_option; |
28 | int a_option; | 28 | int a_option; |
... | @@ -34,9 +34,6 @@ struct mu_option group_a[] = { | ... | @@ -34,9 +34,6 @@ struct mu_option group_a[] = { |
34 | "set file name", | 34 | "set file name", |
35 | mu_c_string, &file_name | 35 | mu_c_string, &file_name |
36 | }, | 36 | }, |
37 | { "find", 'F', "VALUE", MU_OPTION_DEFAULT, | ||
38 | "find VALUE", | ||
39 | mu_c_string, &find_value }, | ||
40 | { "optional", 'o', "FILE", MU_OPTION_ARG_OPTIONAL, | 37 | { "optional", 'o', "FILE", MU_OPTION_ARG_OPTIONAL, |
41 | "optional argument", | 38 | "optional argument", |
42 | mu_c_string, &opt_value }, | 39 | mu_c_string, &opt_value }, |
... | @@ -55,6 +52,9 @@ struct mu_option group_b[] = { | ... | @@ -55,6 +52,9 @@ struct mu_option group_b[] = { |
55 | "another option", | 52 | "another option", |
56 | mu_c_incr, &d_option }, | 53 | mu_c_incr, &d_option }, |
57 | { "verbose", 'v', NULL, MU_OPTION_ALIAS }, | 54 | { "verbose", 'v', NULL, MU_OPTION_ALIAS }, |
55 | { "find", 'F', "VALUE", MU_OPTION_DEFAULT, | ||
56 | "find VALUE", | ||
57 | mu_c_string, &find_value }, | ||
58 | { "jobs", 'j', "N", MU_OPTION_DEFAULT, | 58 | { "jobs", 'j', "N", MU_OPTION_DEFAULT, |
59 | "sets numeric value", | 59 | "sets numeric value", |
60 | mu_c_int, &jobs }, | 60 | mu_c_int, &jobs }, |
... | @@ -71,23 +71,40 @@ main (int argc, char *argv[]) | ... | @@ -71,23 +71,40 @@ main (int argc, char *argv[]) |
71 | struct mu_parseopt po; | 71 | struct mu_parseopt po; |
72 | int rc; | 72 | int rc; |
73 | int i; | 73 | int i; |
74 | int flags = MU_PARSEOPT_DEFAULT; | ||
74 | 75 | ||
75 | mu_stdstream_setup (MU_STDSTREAM_RESET_NONE); | 76 | mu_stdstream_setup (MU_STDSTREAM_RESET_NONE); |
76 | 77 | ||
77 | rc = mu_parseopt (&po, argc, argv, optv, MU_PARSEOPT_DEFAULT); | 78 | if (getenv ("MU_PARSEOPT_DEFAULT")) |
79 | flags = MU_PARSEOPT_DEFAULT; | ||
80 | else | ||
81 | { | ||
82 | if (getenv ("MU_PARSEOPT_IN_ORDER")) | ||
83 | flags |= MU_PARSEOPT_IN_ORDER; | ||
84 | if (getenv ("MU_PARSEOPT_IGNORE_ERRORS")) | ||
85 | flags |= MU_PARSEOPT_IGNORE_ERRORS; | ||
86 | if (getenv ("MU_PARSEOPT_IN_ORDER")) | ||
87 | flags |= MU_PARSEOPT_IN_ORDER; | ||
88 | if (getenv ("MU_PARSEOPT_NO_ERREXIT")) | ||
89 | flags |= MU_PARSEOPT_NO_ERREXIT; | ||
90 | if (getenv ("MU_PARSEOPT_NO_STDOPT")) | ||
91 | flags |= MU_PARSEOPT_NO_STDOPT; | ||
92 | } | ||
93 | |||
94 | rc = mu_parseopt (&po, argc, argv, optv, flags); | ||
78 | printf ("rc=%d\n", rc); | 95 | printf ("rc=%d\n", rc); |
79 | mu_parseopt_apply (&po); | 96 | mu_parseopt_apply (&po); |
80 | 97 | ||
81 | argc -= po.po_ind; | 98 | argc -= po.po_arg_start; |
82 | argv += po.po_ind; | 99 | argv += po.po_arg_start; |
83 | 100 | ||
84 | mu_parseopt_free (&po); | 101 | mu_parseopt_free (&po); |
85 | 102 | ||
86 | printf ("file_name=%s\n", S(file_name)); | 103 | printf ("file_name=%s\n", S(file_name)); |
87 | printf ("find_value=%s\n", S(find_value)); | ||
88 | printf ("opt_value=%s\n", S(opt_value)); | 104 | printf ("opt_value=%s\n", S(opt_value)); |
89 | printf ("x_option=%d\n", x_option); | 105 | printf ("x_option=%d\n", x_option); |
90 | printf ("a_option=%d\n", a_option); | 106 | printf ("a_option=%d\n", a_option); |
107 | printf ("find_value=%s\n", S(find_value)); | ||
91 | printf ("d_option=%d\n", d_option); | 108 | printf ("d_option=%d\n", d_option); |
92 | printf ("jobs=%d\n", jobs); | 109 | printf ("jobs=%d\n", jobs); |
93 | 110 | ... | ... |
libmailutils/tests/parseopt00.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([empty command line]) | ||
18 | AT_KEYWORDS([parseopt parseopt00]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=initial | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | ]) | ||
34 | AT_CLEANUP |
libmailutils/tests/parseopt01.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([command line without options]) | ||
18 | AT_KEYWORDS([parseopt parseopt_noopt parseopt01]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=initial | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt02.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([short options]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt02]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt -f file -x -a -d command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=file | ||
26 | opt_value=initial | ||
27 | x_option=1 | ||
28 | a_option=1 | ||
29 | find_value=(null) | ||
30 | d_option=1 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt03.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([short option with argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt_short_arg parseopt03]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt -ffile -x -a -d command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=file | ||
26 | opt_value=initial | ||
27 | x_option=1 | ||
28 | a_option=1 | ||
29 | find_value=(null) | ||
30 | d_option=1 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt04.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([short option with optional argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt_short_opt_arg parseopt04]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt -ofile command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=file | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt05.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([short option without optional argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt_short_opt_noarg parseopt05]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt -o command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=(null) | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt06.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([incremental short option]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt_short_incr parseopt06]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt -d -d command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=initial | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=2 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt07.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([short option clustering]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt_short_cluster parseopt07]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt -xffile -dado10 command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=file | ||
26 | opt_value=10 | ||
27 | x_option=1 | ||
28 | a_option=1 | ||
29 | find_value=(null) | ||
30 | d_option=2 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt08.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([long options]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt08]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --file=file --all command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=file | ||
26 | opt_value=initial | ||
27 | x_option=0 | ||
28 | a_option=1 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt09.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([long option with argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_long_arg parseopt09]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --file file command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=file | ||
26 | opt_value=initial | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt10.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([long option with optional argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_long_opt_arg parseopt10]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --optional=file command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=file | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt11.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([long option without optional argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_long_opt_noarg parseopt11]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --optional command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=(null) | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt12.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([incremental long option]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_long_incr parseopt12]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --debug --debug command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=(null) | ||
26 | opt_value=initial | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=(null) | ||
30 | d_option=2 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt13.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([abbreviated long options]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_long_abbr parseopt13]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --fil=file --fin=Word command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=file | ||
26 | opt_value=initial | ||
27 | x_option=0 | ||
28 | a_option=0 | ||
29 | find_value=Word | ||
30 | d_option=0 | ||
31 | jobs=0 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt14.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([ambiguous abbreviated long options]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_long_abbr parseopt_long_ambig parseopt14]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --fi=file --fi=Word command line arguments | ||
22 | ], | ||
23 | [1], | ||
24 | [], | ||
25 | [parseopt: option '--fi' is ambiguous; possibilities: | ||
26 | --file | ||
27 | --find | ||
28 | ]) | ||
29 | AT_CLEANUP |
libmailutils/tests/parseopt15.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([mixed long and short options]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_short parseopt15.at]) | ||
19 | AT_CHECK([ | ||
20 | MU_PARSEOPT_DEFAULT=1 | ||
21 | parseopt --file=filename -o -xa --find word -j10 command line arguments | ||
22 | ], | ||
23 | [0], | ||
24 | [rc=0 | ||
25 | file_name=filename | ||
26 | opt_value=(null) | ||
27 | x_option=1 | ||
28 | a_option=1 | ||
29 | find_value=word | ||
30 | d_option=0 | ||
31 | jobs=10 | ||
32 | argv: | ||
33 | 0: command | ||
34 | 1: line | ||
35 | 2: arguments | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt16.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([option aliases]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_short parseopt16.at]) | ||
19 | AT_CHECK([ | ||
20 | parseopt -vvv | ||
21 | ], | ||
22 | [0], | ||
23 | [rc=0 | ||
24 | file_name=(null) | ||
25 | opt_value=initial | ||
26 | x_option=0 | ||
27 | a_option=0 | ||
28 | find_value=(null) | ||
29 | d_option=3 | ||
30 | jobs=0 | ||
31 | argv: | ||
32 | ]) | ||
33 | AT_CLEANUP |
libmailutils/tests/parseopt17.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([argument permutation]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_short parseopt17.at]) | ||
19 | AT_CHECK([ | ||
20 | parseopt more --file=file arguments follow -x -o options | ||
21 | ], | ||
22 | [0], | ||
23 | [rc=0 | ||
24 | file_name=file | ||
25 | opt_value=(null) | ||
26 | x_option=1 | ||
27 | a_option=0 | ||
28 | find_value=(null) | ||
29 | d_option=0 | ||
30 | jobs=0 | ||
31 | argv: | ||
32 | 0: more | ||
33 | 1: arguments | ||
34 | 2: follow | ||
35 | 3: options | ||
36 | ]) | ||
37 | AT_CLEANUP |
libmailutils/tests/parseopt18.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([double-dash]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_short parseopt_double_dash parseopt18.at]) | ||
19 | AT_CHECK([ | ||
20 | parseopt -x --file=foobar -- -a --optional arg | ||
21 | ], | ||
22 | [0], | ||
23 | [rc=0 | ||
24 | file_name=foobar | ||
25 | opt_value=initial | ||
26 | x_option=1 | ||
27 | a_option=0 | ||
28 | find_value=(null) | ||
29 | d_option=0 | ||
30 | jobs=0 | ||
31 | argv: | ||
32 | 0: -a | ||
33 | 1: --optional | ||
34 | 2: arg | ||
35 | ]) | ||
36 | AT_CLEANUP | ||
37 |
libmailutils/tests/parseopt19.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([double-dash with permutation]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_short parseopt_double_dash parseopt19.at]) | ||
19 | AT_CHECK([ | ||
20 | parseopt -x more --file=foobar -- -a --optional arg | ||
21 | ], | ||
22 | [0], | ||
23 | [rc=0 | ||
24 | file_name=foobar | ||
25 | opt_value=initial | ||
26 | x_option=1 | ||
27 | a_option=0 | ||
28 | find_value=(null) | ||
29 | d_option=0 | ||
30 | jobs=0 | ||
31 | argv: | ||
32 | 0: more | ||
33 | 1: -a | ||
34 | 2: --optional | ||
35 | 3: arg | ||
36 | ]) | ||
37 | AT_CLEANUP | ||
38 |
libmailutils/tests/parseopt20.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([short option without required argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt_short_noarg parseopt20]) | ||
19 | AT_CHECK([ | ||
20 | parseopt -f | ||
21 | ], | ||
22 | [1], | ||
23 | [], | ||
24 | [parseopt: option '-f' requires an argument | ||
25 | ]) | ||
26 | AT_CLEANUP | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
libmailutils/tests/parseopt21.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([long option without required argument]) | ||
18 | AT_KEYWORDS([parseopt parseopt_long parseopt_long_noarg parseopt21]) | ||
19 | AT_CHECK([ | ||
20 | parseopt --file | ||
21 | ], | ||
22 | [1], | ||
23 | [], | ||
24 | [parseopt: option '--file' requires an argument | ||
25 | ]) | ||
26 | AT_CLEANUP | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
libmailutils/tests/parseopt22.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([unrecognized option]) | ||
18 | AT_KEYWORDS([parseopt parseopt_short parseopt_short_unrecognized parseopt22]) | ||
19 | AT_CHECK([ | ||
20 | parseopt -X | ||
21 | ], | ||
22 | [1], | ||
23 | [], | ||
24 | [parseopt: unrecognized option '-X' | ||
25 | ]) | ||
26 | AT_CLEANUP | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -15,7 +15,5 @@ | ... | @@ -15,7 +15,5 @@ |
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | AT_SETUP([mu_str_to_c]) | 17 | AT_SETUP([mu_str_to_c]) |
18 | |||
19 | AT_CHECK([strtoc]) | 18 | AT_CHECK([strtoc]) |
20 | |||
21 | AT_CLEANUP | 19 | AT_CLEANUP | ... | ... |
... | @@ -56,6 +56,31 @@ AT_INIT | ... | @@ -56,6 +56,31 @@ AT_INIT |
56 | AT_BANNER([Conversions]) | 56 | AT_BANNER([Conversions]) |
57 | m4_include([strtoc.at]) | 57 | m4_include([strtoc.at]) |
58 | 58 | ||
59 | AT_BANNER([Command line parser]) | ||
60 | m4_include([parseopt00.at]) | ||
61 | m4_include([parseopt01.at]) | ||
62 | m4_include([parseopt02.at]) | ||
63 | m4_include([parseopt03.at]) | ||
64 | m4_include([parseopt04.at]) | ||
65 | m4_include([parseopt05.at]) | ||
66 | m4_include([parseopt06.at]) | ||
67 | m4_include([parseopt07.at]) | ||
68 | m4_include([parseopt08.at]) | ||
69 | m4_include([parseopt09.at]) | ||
70 | m4_include([parseopt10.at]) | ||
71 | m4_include([parseopt11.at]) | ||
72 | m4_include([parseopt12.at]) | ||
73 | m4_include([parseopt13.at]) | ||
74 | m4_include([parseopt14.at]) | ||
75 | m4_include([parseopt15.at]) | ||
76 | m4_include([parseopt16.at]) | ||
77 | m4_include([parseopt17.at]) | ||
78 | m4_include([parseopt18.at]) | ||
79 | m4_include([parseopt19.at]) | ||
80 | m4_include([parseopt20.at]) | ||
81 | m4_include([parseopt21.at]) | ||
82 | m4_include([parseopt22.at]) | ||
83 | |||
59 | AT_BANNER([Standard streams]) | 84 | AT_BANNER([Standard streams]) |
60 | m4_include([strin.at]) | 85 | m4_include([strin.at]) |
61 | m4_include([strout.at]) | 86 | m4_include([strout.at]) | ... | ... |
-
Please register or sign in to post a comment