tests: Fix error in man check specification
[openafs.git] / tests / cmd / command-t.c
index b576048..a4248c2 100644 (file)
@@ -38,6 +38,7 @@
 #define FLAG_OFF    0
 #define FIRST_OFF   1
 #define SECOND_OFF  2
+#define SUGAR_OFF   3
 #define FOURTH_OFF  4
 #define FIFTH_OFF   5
 #define PERHAPS_OFF 6
@@ -67,7 +68,7 @@ main(int argc, char **argv)
     int retval;
     char *retstring = NULL;
 
-    plan(79);
+    plan(85);
 
     initialize_CMD_error_table();
 
@@ -154,6 +155,19 @@ main(int argc, char **argv)
     is_int(CMD_UNKNOWNSWITCH, code, "and fail with cmd_Parse too");
     cmd_FreeArgv(tv);
 
+    /* Check that paramaters with abbreviation disabled don't make things
+     * ambiguous */
+    cmd_AddParmAtOffset(opts, SUGAR_OFF, "-sugar", CMD_SINGLE, CMD_OPTIONAL | CMD_NOABBRV,
+                       "sugar with that");
+    code = cmd_ParseLine("-fi foo -s bar -flag", tv, &tc, 100);
+    is_int(0, code, "cmd_ParseLine succeeds");
+    code = cmd_Dispatch(tc, tv);
+    is_int(0, code, "disabling specific abbreviations succeeds");
+    code = cmd_Parse(tc, tv, &retopts);
+    is_int(0, code, "and works with cmd_Parse into the bargain");
+    cmd_FreeOptions(&retopts);
+    cmd_FreeArgv(tv);
+
     /* Disable positional commands */
     cmd_DisablePositionalCommands();
     code = cmd_ParseLine("foo bar -flag", tv, &tc, 100);
@@ -187,10 +201,10 @@ main(int argc, char **argv)
     cmd_FreeOptions(&retopts);
     cmd_FreeArgv(tv);
     /* Try adding a couple of parameters at specific positions */
-    cmd_AddParmAtOffset(opts, "-fifth", CMD_SINGLE, CMD_OPTIONAL,
-                      "fifth option", FIFTH_OFF);
-    cmd_AddParmAtOffset(opts, "-fourth", CMD_SINGLE, CMD_OPTIONAL,
-                      "fourth option", FOURTH_OFF);
+    cmd_AddParmAtOffset(opts, FIFTH_OFF, "-fifth", CMD_SINGLE, CMD_OPTIONAL,
+                      "fifth option");
+    cmd_AddParmAtOffset(opts, FOURTH_OFF, "-fourth", CMD_SINGLE, CMD_OPTIONAL,
+                      "fourth option" );
     code = cmd_ParseLine("-first a -fourth b -fifth c", tv, &tc, 100);
     is_int(0, code, "cmd_ParseLine succeeds");
     code = cmd_Parse(tc, tv, &retopts);