FileDocCategorySizeDatePackage
GetOptTest.javaAPI DocExample1314Sun Apr 15 14:50:56 BST 2001None

GetOptTest

public class GetOptTest extends Object
Some test cases for GetOpt.
author
Ian F. Darwin, ian@darwinsys.com
version
$Id: GetOptTest.java,v 1.4 2001/04/15 17:50:56 ian Exp $

Fields Summary
static String
goodArgChars
static String[]
goodArgs
static String
badArgChars
static String[]
badArgs
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		process(goodArgChars, goodArgs);
		process(badArgChars, goodArgs);
		process(badArgChars, badArgs);
	
private static voidprocess(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");
		}