From: Christopher Allan Webber Date: Thu, 19 Nov 2015 04:33:18 +0000 (-0600) Subject: Add final queue-based tests for time segments / schedule stuff X-Git-Tag: v0.1.0~160 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=b5470d453b613ffd7f639b48af9febcf57a92a70;p=8sync.git Add final queue-based tests for time segments / schedule stuff --- diff --git a/tests.scm b/tests.scm index 228f39f..84bf8f3 100644 --- a/tests.scm +++ b/tests.scm @@ -119,7 +119,38 @@ (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