File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import Utility.sbToString
2626sealed abstract class Decl
2727
2828sealed abstract class MarkupDecl extends Decl {
29+ override def toString (): String = sbToString(buildString)
2930 def buildString (sb : StringBuilder ): StringBuilder
3031}
3132
Original file line number Diff line number Diff line change 1+ package scala .xml
2+ package dtd
3+
4+ import org .junit .Test
5+ import org .junit .Assert .assertEquals
6+
7+ class DeclTest {
8+
9+ @ Test
10+ def elemDeclToString : Unit = {
11+ assertEquals(
12+ " <!ELEMENT x (#PCDATA)>" ,
13+ ElemDecl (" x" , PCDATA ).toString
14+ )
15+ }
16+
17+ @ Test
18+ def attListDeclToString : Unit = {
19+
20+ val expected =
21+ """ |<!ATTLIST x
22+ | y CDATA #REQUIRED
23+ | z CDATA #REQUIRED>""" .stripMargin
24+
25+ val actual = AttListDecl (" x" ,
26+ List (
27+ AttrDecl (" y" , " CDATA" , REQUIRED ),
28+ AttrDecl (" z" , " CDATA" , REQUIRED )
29+ )
30+ ).toString
31+
32+ assertEquals(expected, actual)
33+ }
34+
35+ @ Test
36+ def parsedEntityDeclToString : Unit = {
37+ assertEquals(
38+ """ <!ENTITY foo SYSTEM "bar">""" ,
39+ ParsedEntityDecl (" foo" , ExtDef (SystemID (" bar" ))).toString
40+ )
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments