Skip to content
This repository
Browse code

Corrected invalid char checks in canonicalization specs

  • Loading branch information...
commit d8692870542a78b4735487e4d4c9b9d39b3a17fe 1 parent 0df9876
Daniel Spiewak authored
24  src/test/scala/com/codecommit/antixml/GroupSpecs.scala
@@ -225,51 +225,51 @@ class GroupSpecs extends Specification with ScalaCheck with XMLGenerators with U
225 225
     }
226 226
   }
227 227
 
228  
-  val BadChars = "([\u0000-\u0008]|[\u000B-\u000C]|[\u000E-\u001F]|[\uD800-\uDFFF]|[\uFFFF])"r
229  
-  
230 228
   "canonicalization" should {
  229
+    import Node.CharRegex
  230
+    
231 231
     "merge two adjacent text nodes" in check { (left: String, right: String) =>
232  
-      if (BadChars.findFirstIn(left+right).isEmpty) {
  232
+      if (!CharRegex.unapplySeq(left + right).isEmpty) {
233 233
         Group(Text(left), Text(right)).canonicalize mustEqual Group(Text(left + right))
234 234
         Group(CDATA(left), CDATA(right)).canonicalize mustEqual Group(CDATA(left + right))
235 235
       } else {
236  
-        Text(left+right) must throwAn[IllegalArgumentException]
  236
+        Text(left + right) must throwAn[IllegalArgumentException]
237 237
       }
238 238
     }
239 239
     
240 240
     "merge two adjacent text nodes at end of Group" in check { (left: String, right: String) =>
241  
-      if (BadChars.findFirstIn(left+right).isEmpty) {
  241
+      if (!CharRegex.unapplySeq(left + right).isEmpty) {
242 242
         Group(elem("foo"), elem("bar", Text("test")), Text(left), Text(right)).canonicalize mustEqual Group(elem("foo"), elem("bar", Text("test")), Text(left + right))
243 243
         Group(elem("foo"), elem("bar", Text("test")), CDATA(left), CDATA(right)).canonicalize mustEqual Group(elem("foo"), elem("bar", Text("test")), CDATA(left + right))
244 244
       } else {
245  
-        Text(left+right) must throwAn[IllegalArgumentException]
  245
+        Text(left + right) must throwAn[IllegalArgumentException]
246 246
       }
247 247
     }
248 248
     
249 249
     "merge two adjacent text nodes at beginning of Group" in check { (left: String, right: String) =>
250  
-      if (BadChars.findFirstIn(left+right).isEmpty) {
  250
+      if (!CharRegex.unapplySeq(left + right).isEmpty) {
251 251
         Group(Text(left), Text(right), elem("foo"), elem("bar", Text("test"))).canonicalize mustEqual Group(Text(left + right), elem("foo"), elem("bar", Text("test")))
252 252
         Group(CDATA(left), CDATA(right), elem("foo"), elem("bar", Text("test"))).canonicalize mustEqual Group(CDATA(left + right), elem("foo"), elem("bar", Text("test")))
253 253
       } else {
254  
-        Text(left+right) must throwAn[IllegalArgumentException]
  254
+        Text(left + right) must throwAn[IllegalArgumentException]
255 255
       }
256 256
     }
257 257
     
258 258
     "merge two adjacent text nodes at depth" in check { (left: String, right: String) =>
259  
-      if (BadChars.findFirstIn(left+right).isEmpty) {
  259
+      if (!CharRegex.unapplySeq(left + right).isEmpty) {
260 260
         Group(elem("foo", elem("bar", Text(left), Text(right)))).canonicalize mustEqual Group(elem("foo", elem("bar", Text(left + right))))
261 261
         Group(elem("foo", elem("bar", CDATA(left), CDATA(right)))).canonicalize mustEqual Group(elem("foo", elem("bar", CDATA(left + right))))
262 262
       } else {
263  
-        Text(left+right) must throwAn[IllegalArgumentException]
  263
+        Text(left + right) must throwAn[IllegalArgumentException]
264 264
       }
265 265
     }
266 266
     
267 267
     "not merge adjacent text and cdata nodes" in check { (left: String, right: String) =>
268  
-      if (BadChars.findFirstIn(left+right).isEmpty) {
  268
+      if (!CharRegex.unapplySeq(left + right).isEmpty) {
269 269
         Group(CDATA(left), Text(right)).canonicalize mustEqual Group(CDATA(left), Text(right))
270 270
         Group(Text(left), CDATA(right)).canonicalize mustEqual Group(Text(left), CDATA(right))
271 271
       } else {
272  
-        Text(left+right) must throwAn[IllegalArgumentException]
  272
+        Text(left + right) must throwAn[IllegalArgumentException]
273 273
       }
274 274
     }
275 275
     

0 notes on commit d869287

Please sign in to comment.
Something went wrong with that request. Please try again.