GetOptTestpublic class GetOptTest extends Object Some test cases for GetOpt. |
Fields Summary |
---|
static String | goodArgChars | static String[] | goodArgs | static String | badArgChars | static String[] | badArgs |
Methods Summary |
---|
public static void | main(java.lang.String[] args)
process(goodArgChars, goodArgs);
process(badArgChars, goodArgs);
process(badArgChars, badArgs);
| private static void | process(java.lang.String argChars, java.lang.String[] args)Private function, for testing.
System.out.println("** START ** " + argChars + '(" + args.length + ')");
GetOpt go = new GetOpt(argChars);
char c;
int errs = 0;
while ((c =go.getopt(args)) != 0) {
if (c == '?") {
System.out.print("Bad option");
++errs;
} else {
System.out.print("Found " + c);
if (go.optarg() != null)
System.out.print("; Option " + go.optarg());
}
System.out.println();
}
// Process any filename-like arguments.
for (int i=go.getOptInd(); i<args.length; i++)
System.out.println("Filename-like arg " + args[i]);
if (errs != 0) {
System.out.println("At least one user error found");
}
|
|