import testing.SUnit._
object Test extends TestConsoleMain {
import scala.xml.{NodeSeq, Utility}
import NodeSeq.view
val ax =
val cx =
crazy text world
val bx =
object XmlEx extends TestCase("attributes") with Assert {
override def runTest = {
assertTrue("@one", ax \ "@foo" == "bar") // uses NodeSeq.view!
assertTrue("@two", ax \ "@foo" == xml.Text("bar")) // dto.
assertTrue("@three", bx \ "@foo" == "bar&x") // dto.
assertTrue ("@four", (bx \ "@foo") sameElements List(xml.Text("bar&x")))
//assertTrue("@four", (bx \ "@foo") sameElements List(xml.Text("bar"),xml.EntityRef("amp"),xml.Text("x")))
assertEquals("@five", "", bx.toString)
}
}
object XmlPat extends TestCase("patterns") with Assert {
override def runTest = {
assertTrue( match { case => true; case _ => false; })
assertTrue( match { case => true; case _ => false; });
assertTrue(Utility.trim(cx) match { case n @ crazy text world if n \ "@foo" == "bar" => true; })
assertTrue(Utility.trim(cx) match { case n @ crazy text world if n \ "@foo" == "bar" => true; })
}
}
object DodgyNamespace extends TestCase("DodgyNamespace") with Assert {
override def runTest = {
val x =
assertTrue(x.toString.contains("xmlns:dog=\"http://dog.com\""));
}
}
def suite = new TestSuite(
XmlEx,
XmlPat,
DodgyNamespace
)
}