public void testSkipForwardToEndOfXmlTag() { qedeqInput.skipForwardToEndOfXmlTag(); assertEquals('\n', qedeqInput.getChar()); qedeqInput.skipForwardToEndOfXmlTag(); assertEquals('\n', qedeqInput.read()); assertEquals(" <HEADER", qedeqInput.readString(" <HEADER".length())); final TextInput ti = new TextInput("<Head this=\">is not the end\">zulu"); ti.skipForwardToEndOfXmlTag(); assertEquals("zulu", ti.readString(4)); final TextInput ti2 = new TextInput("<Head this=\"one\" that=\"two\">zulu"); ti2.skipForwardToEndOfXmlTag(); assertEquals("zulu", ti2.readString(4)); final TextInput ti3 = new TextInput("<Head this=\"one\" that=\"two>zulu"); try { ti3.skipForwardToEndOfXmlTag(); fail("Exception expected"); // the quotation is not ended! } catch (RuntimeException e) { // OK } final TextInput ti4 = new TextInput("<Head this=\"one\" that=\"two\" this= that"); try { ti4.skipForwardToEndOfXmlTag(); fail("Exception expected"); // the tag is not ended with > } catch (RuntimeException e) { // OK } }
/** Test {@link TextInput#readQuoted()}. */ public void testReadQuoted() { final TextInput first = new TextInput("Hell=\"one\" Water=\"two\""); first.setPosition(5); assertEquals("one", first.readQuoted()); first.readString(7); assertEquals("two", first.readQuoted()); final TextInput second = new TextInput("\"\"\"one\" Water=\"two\""); assertEquals("\"one", second.readQuoted()); second.setPosition(1); assertEquals("", second.readQuoted()); final int position = second.getPosition(); try { second.readQuoted(); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected } assertTrue(position < second.getPosition()); }
/** Test {@link TextInput#read()}. */ public void testReadString() { qedeqInput.read(); qedeqInput.read(); assertEquals("xml", qedeqInput.readString(3)); }