Method to check whether a (sorted) list of timeslots contains gaps
authorGeorgios Gousios <gousiosg@gmail.com>
Tue, 7 Feb 2012 14:48:22 +0000 (16:48 +0200)
committerGeorgios Gousios <gousiosg@gmail.com>
Tue, 7 Feb 2012 14:48:22 +0000 (16:48 +0200)
src/test/scala/gr/grnet/aquarium/logic/test/DSLTestBase.scala

index b32bbfc..3e4ca9e 100644 (file)
@@ -60,7 +60,16 @@ class DSLTestBase extends DSL {
     if (result.isEmpty) return
     if (result.tail.isEmpty) return
     if (result.head.to.after(result.tail.head.from))
-      fail("Effectivity timeslots not successive: %s %s".format(result.head, result.tail.head))
+      fail("Timeslots not successive: %s %s".format(result.head, result.tail.head))
     testSuccessiveTimeslots(result.tail)
   }
+
+  @tailrec
+  final def testNoGaps(result: List[Timeslot]): Unit = {
+    if (result.isEmpty) return
+    if (result.tail.isEmpty) return
+    if (result.head.to.getTime != result.tail.head.from.getTime + 1)
+      fail("Timeslots not successive: %s %s".format(result.head, result.tail.head))
+    testNoGaps(result.tail)
+  }
 }
\ No newline at end of file