Permalink
Browse files

Corrected invalid char checks in canonicalization specs

  • Loading branch information...
1 parent 0df9876 commit d8692870542a78b4735487e4d4c9b9d39b3a17fe @djspiewak committed Oct 2, 2011
Showing with 12 additions and 12 deletions.
  1. +12 −12 src/test/scala/com/codecommit/antixml/GroupSpecs.scala
@@ -225,51 +225,51 @@ class GroupSpecs extends Specification with ScalaCheck with XMLGenerators with U
}
}
- val BadChars = "([\u0000-\u0008]|[\u000B-\u000C]|[\u000E-\u001F]|[\uD800-\uDFFF]|[\uFFFF])"r
-
"canonicalization" should {
+ import Node.CharRegex
+
"merge two adjacent text nodes" in check { (left: String, right: String) =>
- if (BadChars.findFirstIn(left+right).isEmpty) {
+ if (!CharRegex.unapplySeq(left + right).isEmpty) {
Group(Text(left), Text(right)).canonicalize mustEqual Group(Text(left + right))
Group(CDATA(left), CDATA(right)).canonicalize mustEqual Group(CDATA(left + right))
} else {
- Text(left+right) must throwAn[IllegalArgumentException]
+ Text(left + right) must throwAn[IllegalArgumentException]
}
}
"merge two adjacent text nodes at end of Group" in check { (left: String, right: String) =>
- if (BadChars.findFirstIn(left+right).isEmpty) {
+ if (!CharRegex.unapplySeq(left + right).isEmpty) {
Group(elem("foo"), elem("bar", Text("test")), Text(left), Text(right)).canonicalize mustEqual Group(elem("foo"), elem("bar", Text("test")), Text(left + right))
Group(elem("foo"), elem("bar", Text("test")), CDATA(left), CDATA(right)).canonicalize mustEqual Group(elem("foo"), elem("bar", Text("test")), CDATA(left + right))
} else {
- Text(left+right) must throwAn[IllegalArgumentException]
+ Text(left + right) must throwAn[IllegalArgumentException]
}
}
"merge two adjacent text nodes at beginning of Group" in check { (left: String, right: String) =>
- if (BadChars.findFirstIn(left+right).isEmpty) {
+ if (!CharRegex.unapplySeq(left + right).isEmpty) {
Group(Text(left), Text(right), elem("foo"), elem("bar", Text("test"))).canonicalize mustEqual Group(Text(left + right), elem("foo"), elem("bar", Text("test")))
Group(CDATA(left), CDATA(right), elem("foo"), elem("bar", Text("test"))).canonicalize mustEqual Group(CDATA(left + right), elem("foo"), elem("bar", Text("test")))
} else {
- Text(left+right) must throwAn[IllegalArgumentException]
+ Text(left + right) must throwAn[IllegalArgumentException]
}
}
"merge two adjacent text nodes at depth" in check { (left: String, right: String) =>
- if (BadChars.findFirstIn(left+right).isEmpty) {
+ if (!CharRegex.unapplySeq(left + right).isEmpty) {
Group(elem("foo", elem("bar", Text(left), Text(right)))).canonicalize mustEqual Group(elem("foo", elem("bar", Text(left + right))))
Group(elem("foo", elem("bar", CDATA(left), CDATA(right)))).canonicalize mustEqual Group(elem("foo", elem("bar", CDATA(left + right))))
} else {
- Text(left+right) must throwAn[IllegalArgumentException]
+ Text(left + right) must throwAn[IllegalArgumentException]
}
}
"not merge adjacent text and cdata nodes" in check { (left: String, right: String) =>
- if (BadChars.findFirstIn(left+right).isEmpty) {
+ if (!CharRegex.unapplySeq(left + right).isEmpty) {
Group(CDATA(left), Text(right)).canonicalize mustEqual Group(CDATA(left), Text(right))
Group(Text(left), CDATA(right)).canonicalize mustEqual Group(Text(left), CDATA(right))
} else {
- Text(left+right) must throwAn[IllegalArgumentException]
+ Text(left + right) must throwAn[IllegalArgumentException]
}
}

0 comments on commit d869287

Please sign in to comment.