int test;
int verbose;
char *file;
+ int read;
char *hidden;
int opt;
char *optional;
{ "verbose", 'v', NULL, 0, "Simple option without arguments", 1 },
{ "file", 'f', "FILE", 0, "Option with a mandatory argument", 1 },
{ "input", 0, NULL, OPTION_ALIAS, NULL, 1 },
+ { "read", 'r', NULL, OPTION_ALIAS, NULL, 1 },
{ "hidden", 'H', "FILE", OPTION_HIDDEN, "Hidden option", 1 },
{ NULL, 0, NULL, 0, NULL, 0 }
};
args->verbose++;
break;
+ case 'r':
+ args->read = 1;
+ /* fall through */
case 'f':
args->file = arg;
break;
#define INIT_TEST_COMMON(n) \
int argc = NARGS (argv); \
struct test_args test_args; \
- init_args(test_args); \
+ init_args (test_args); \
test_number = n;
#define INIT_TEST1(n, arg1) \
char *argv[] = { ARGV0, arg1, NULL }; \
- INIT_TEST_COMMON(n)
+ INIT_TEST_COMMON (n)
#define INIT_TEST2(n, arg1, arg2) \
char *argv[] = { ARGV0, arg1, arg2, NULL }; \
- INIT_TEST_COMMON(n)
+ INIT_TEST_COMMON (n)
#define INIT_TEST3(n, arg1, arg2, arg3) \
char *argv[] = { ARGV0, arg1, arg2, arg3, NULL }; \
- INIT_TEST_COMMON(n)
+ INIT_TEST_COMMON (n)
int test_number;
unsigned failure_count = 0;
void
test_optional (struct argp *argp, int argc, char **argv,
- struct test_args *args, char *val, char *a)
+ struct test_args *args, const char *val, const char *a)
{
int index;
if (argp_parse (argp, argc, argv, 0, &index, args))
fail ("option not processed");
}
+void
+test15 (struct argp *argp)
+{
+ INIT_TEST2 (1, "-r", "FILE");
+ test_file (argp, argc, argv, &test_args);
+ if (!test_args.read)
+ fail ("short alias not recognized properly");
+}
typedef void (*test_fp) (struct argp *argp);
test1, test2, test3, test4,
test5, test6, test7, test8,
test9, test10, test11, test12,
- test13, test14,
+ test13, test14, test15,
NULL
};