public void testMixed(){
  ArgumentParser parser=new ArgumentParser(new String[]{"-xcf","myfile.tgz","file1","file2","--verbose"},true);
  Iterator<String> iter=parser.iterator();
  assertEquals("-x",iter.next());
  assertEquals("-c",iter.next());
  assertEquals("-f",iter.next());
  assertEquals("myfile.tgz",iter.next());
  assertEquals("file1",iter.next());
  assertEquals("file2",iter.next());
  assertEquals("--verbose",iter.next());
  assertIteratorAtEnd(iter);
  parser=new ArgumentParser(new String[]{"-xcf","myfile.tgz","file1","file2","--verbose"},false);
  iter=parser.iterator();
  assertEquals("-xcf",iter.next());
  assertEquals("myfile.tgz",iter.next());
  assertEquals("file1",iter.next());
  assertEquals("file2",iter.next());
  assertEquals("--verbose",iter.next());
  assertIteratorAtEnd(iter);
  parser=new ArgumentParser(new String[]{"-xcf","=","=a","=ab","-=","-=a","--=","--=a","--a=b"},false);
  iter=parser.iterator();
  assertEquals("-xcf",iter.next());
  assertEquals("=",iter.next());
  assertEquals("=a",iter.next());
  assertEquals("=ab",iter.next());
  assertEquals("-=",iter.next());
  assertEquals("-=a",iter.next());
  assertEquals("--=",iter.next());
  assertEquals("--=a",iter.next());
  assertEquals("--a",iter.next());
  assertEquals("b",iter.next());
  assertIteratorAtEnd(iter);
}

public void testMixed ( ) { ArgumentParser parser = new ArgumentParser ( new String [ ] { "-xcf" , "myfile.tgz" , "file1" , "file2" , "--verbose" } , true ) ; Iterator < String > iter = parser . iterator ( ) ; assertEquals ( "-x" , iter . next ( ) ) ; assertEquals ( "-c" , iter . next ( ) ) ; assertEquals ( "-f" , iter . next ( ) ) ; assertEquals ( "myfile.tgz" , iter . next ( ) ) ; assertEquals ( "file1" , iter . next ( ) ) ; assertEquals ( "file2" , iter . next ( ) ) ; assertEquals ( "--verbose" , iter . next ( ) ) ; assertIteratorAtEnd ( iter ) ; parser = new ArgumentParser ( new String [ ] { "-xcf" , "myfile.tgz" , "file1" , "file2" , "--verbose" } , false ) ; iter = parser . iterator ( ) ; assertEquals ( "-xcf" , iter . next ( ) ) ; assertEquals ( "myfile.tgz" , iter . next ( ) ) ; assertEquals ( "file1" , iter . next ( ) ) ; assertEquals ( "file2" , iter . next ( ) ) ; assertEquals ( "--verbose" , iter . next ( ) ) ; assertIteratorAtEnd ( iter ) ; parser = new ArgumentParser ( new String [ ] { "-xcf" , "=" , "=a" , "=ab" , "-=" , "-=a" , "--=" , "--=a" , "--a=b" } , false ) ; iter = parser . iterator ( ) ; assertEquals ( "-xcf" , iter . next ( ) ) ; assertEquals ( "=" , iter . next ( ) ) ; assertEquals ( "=a" , iter . next ( ) ) ; assertEquals ( "=ab" , iter . next ( ) ) ; assertEquals ( "-=" , iter . next ( ) ) ; assertEquals ( "-=a" , iter . next ( ) ) ; assertEquals ( "--=" , iter . next ( ) ) ; assertEquals ( "--=a" , iter . next ( ) ) ; assertEquals ( "--a" , iter . next ( ) ) ; assertEquals ( "b" , iter . next ( ) ) ; assertIteratorAtEnd ( iter ) ; }
test if a mix of arguments and options are correctly recognized .
