Пример #1
0
 void assertOptionsFail(String s) {
   try {
     Parser.parseOption(tokenize(s));
     fail("Successfully parsed invalid string: " + s);
   } catch (Parser.ParseError e) {
   }
 }
Пример #2
0
  public void testParseOption() throws Exception {
    Parser.ParseOptionResult r;

    r = Parser.parseOption(tokenize("key=value baz"));
    assertEquals("key", r.key);
    assertEquals("value", r.value);
    r = Parser.parseOption(tokenize("key    = value baz"));
    assertEquals("key", r.key);
    assertEquals("value", r.value);
    r = Parser.parseOption(tokenize("\"key\" = \"value\" baz"));
    assertEquals("key", r.key);
    assertEquals("value", r.value);

    assertOptionFail("key=");
    assertOptionFail("=value");
    assertOptionFail("key");
    assertOptionFail("key value");
    assertOptionFail(" = ");
  }