diff options
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/test/java/libcore/xml/PullParserTest.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/xml/PullParserTest.java b/luni/src/test/java/libcore/xml/PullParserTest.java index 71125aa..c59b358 100644 --- a/luni/src/test/java/libcore/xml/PullParserTest.java +++ b/luni/src/test/java/libcore/xml/PullParserTest.java @@ -742,8 +742,42 @@ public abstract class PullParserTest extends TestCase { assertEquals("foo", parser.getName()); } + public void testEofInElementSpecRelaxed() throws Exception { + assertRelaxedParseFailure("<!DOCTYPE foo [<!ELEMENT foo (unterminated"); + } + + public void testEofInAttributeValue() throws Exception { + assertParseFailure("<!DOCTYPE foo [<!ATTLIST foo x y \"unterminated"); + } + + public void testEofInEntityValue() throws Exception { + assertParseFailure("<!DOCTYPE foo [<!ENTITY aaa \"unterminated"); + } + + public void testEofInStartTagAttributeValue() throws Exception { + assertParseFailure("<long foo=\"unterminated"); + } + + public void testEofInReadCharRelaxed() throws Exception { + assertRelaxedParseFailure("<!DOCTYPE foo [<!ELEMENT foo ()"); // EOF in read('>') + } + + public void testEofAfterReadCharArrayRelaxed() throws Exception { + assertRelaxedParseFailure("<!DOCTYPE foo [<!ELEMENT foo EMPTY"); // EOF in read('>') + } + private void assertParseFailure(String xml) throws Exception { XmlPullParser parser = newPullParser(); + assertParseFailure(xml, parser); + } + + private void assertRelaxedParseFailure(String xml) throws Exception { + XmlPullParser parser = newPullParser(); + parser.setFeature("http://xmlpull.org/v1/doc/features.html#relaxed", true); + assertParseFailure(xml, parser); + } + + private void assertParseFailure(String xml, XmlPullParser parser) throws Exception { parser.setInput(new StringReader(xml)); try { while (parser.next() != XmlPullParser.END_DOCUMENT) { |