graphgif/test.scm

21 lines
704 B
Scheme
Raw Permalink Normal View History

(use-modules (rnrs base)
(d-)
(graphgif))
(begin
(display "Testing heap operations...")
(newline)
(let ([heap (~>> #()
(heap-insert (inf) 1)
(heap-insert (inf) 2)
(heap-insert (inf) 3)
(heap-insert 0 1))])
(assert (equal? (heap-peek heap) '(0 . 1)))
(set! heap (heap-insert 1 2 (heap-pop heap)))
(assert (equal? (heap-peek heap) '(1 . 2)))
(set! heap (heap-insert 3 3 heap))
(assert (equal? (heap-peek heap) '(1 . 2)))
(assert (equal? (heap-peek (heap-pop heap)) '(3 . 3))))
(assert (equal? (heap-pop #((0 . 0))) #()))
(assert (equal? (heap-peek (heap-pop (heap-pop #((1 . 1) (1 . 10) (+inf.0 . 2) (+inf.0 . 3) (1 . 11))))) '(1 . 11))))