Skip to content

Commit d5609e3

Browse files
committed
Add descendant XML attribute unit tests
1 parent 72b11f6 commit d5609e3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/scala/scala/xml/AttributeTest.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,30 @@ class AttributeTest {
104104
assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \\ "@bar"))
105105
}
106106

107+
@Test
108+
def attributeDescendantPathChildAttributes: Unit = {
109+
val xml = <a><b bar="1" /><b bar="2" /></a>
110+
assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \ "b" \\ "@bar"))
111+
}
112+
113+
@Test
114+
def attributeDescendantPathDescendantAttributes: Unit = {
115+
val xml = <a><b bar="1" /><b bar="2" /></a>
116+
assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \\ "b" \\ "@bar"))
117+
}
118+
119+
@Test
120+
def attributeChildDescendantPathDescendantAttributes: Unit = {
121+
val xml = <x><a><b bar="1" /><b bar="2" /></a></x>
122+
assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \ "a" \\ "@bar"))
123+
}
124+
125+
@Test
126+
def attributeDescendantDescendantPathDescendantAttributes: Unit = {
127+
val xml = <x><a><b bar="1" /><b bar="2" /></a></x>
128+
assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \\ "b" \\ "@bar"))
129+
}
130+
107131
@Test(expected=classOf[IllegalArgumentException])
108132
def attributePathDescendantIllegalEmptyAttribute: Unit = {
109133
val xml = <foo />

0 commit comments

Comments
 (0)