Add final queue-based tests for time segments / schedule stuff
authorChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 19 Nov 2015 04:33:18 +0000 (22:33 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 19 Nov 2015 04:33:18 +0000 (22:33 -0600)
tests.scm

index 228f39febd19cf9c656fb9db99bbf35d758fb0f2..84bf8f35b32e3f1ae0b69e266622e09d1bdad3b4 100644 (file)
--- a/tests.scm
+++ b/tests.scm
   (schedule-extract-until! sched 10))
 (assert-times-expected some-extracted '((8 . 1) (10 . 0)))
 (assert-times-expected (schedule-segments sched) '((10 . 10) (11 . 0)))
-
+(define first-extracted-queue
+  (time-segment-queue (car some-extracted)))
+(define second-extracted-queue
+  (time-segment-queue (cadr some-extracted)))
+(test-assert (not (q-empty? first-extracted-queue)))
+(test-equal ((deq! first-extracted-queue)) 'd)
+(test-assert (q-empty? first-extracted-queue))
+
+(test-assert (not (q-empty? second-extracted-queue)))
+(test-equal ((deq! second-extracted-queue)) 'a)
+(test-equal ((deq! second-extracted-queue)) 'b)
+(test-assert (q-empty? second-extracted-queue))
+
+;; Add one more and test flattening to a queue
+(test-assert (not (schedule-empty? sched)))
+(schedule-add! '(10 . 10) f-proc sched)
+(define remaining-segments
+  (schedule-extract-until! sched '(9000 . 1)))
+(test-assert (schedule-empty? sched))
+(define some-queue (make-q))
+(enq! some-queue (const 'ho-ho))
+(enq! some-queue (const 'ha-ha))
+(add-segments-contents-to-queue! remaining-segments some-queue)
+(test-assert (not (q-empty? some-queue)))
+(test-equal 'ho-ho ((deq! some-queue)))
+(test-equal 'ha-ha ((deq! some-queue)))
+(test-equal 'e ((deq! some-queue)))
+(test-equal 'f ((deq! some-queue)))
+(test-equal 'c ((deq! some-queue)))
+(test-assert (q-empty? some-queue))
+
+;; ... whew!
 
 ;; End tests