Skip to content

Commit ca3e8ce

Browse files
committed
Fix unit tests on malformed input.
Verify to throw FatalError at a broken CDATA section and comment.
1 parent ea92325 commit ca3e8ce

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/test/scala/scala/xml/pull/XMLEventReaderTest.scala

+12-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.junit.Test
55
import org.junit.Assert.{assertFalse, assertTrue}
66

77
import scala.io.Source
8+
import scala.xml.parsing.FatalError
89

910
class XMLEventReaderTest {
1011

@@ -49,28 +50,32 @@ class XMLEventReaderTest {
4950
assertTrue(r.next.isInstanceOf[EvElemStart])
5051
}
5152

52-
@Test
53+
@Test(expected = classOf[FatalError])
5354
def malformedCDATA: Unit = {
5455
val data = "<broken><![CDATA[A"
5556
val r = new XMLEventReader(toSource(data))
5657

5758
assertTrue(r.next.isInstanceOf[EvElemStart])
59+
// error when returning EvText of CDATA
60+
r.next
5861
}
5962

60-
@Test
63+
@Test(expected = classOf[FatalError])
6164
def malformedComment1: Unit = {
62-
val data = "<broken><!"
65+
val data = "<!"
6366
val r = new XMLEventReader(toSource(data))
6467

65-
assertTrue(r.next.isInstanceOf[EvElemStart])
68+
// error when returning EvComment
69+
r.next
6670
}
6771

68-
@Test
72+
@Test(expected = classOf[FatalError])
6973
def malformedComment2: Unit = {
70-
val data = "<broken><!-- comment "
74+
val data = "<!-- comment "
7175
val r = new XMLEventReader(toSource(data))
7276

73-
assertTrue(r.next.isInstanceOf[EvElemStart])
77+
// error when returning EvComment
78+
r.next
7479
}
7580

7681
@Test

0 commit comments

Comments
 (0)