Rename for consistency
This commit is contained in:
parent
e67e57b604
commit
3e2ff86eec
3 changed files with 3 additions and 2 deletions
62
tests/priority-queue.scm
Normal file
62
tests/priority-queue.scm
Normal file
|
@ -0,0 +1,62 @@
|
|||
(use-modules (algorithms priority-queue)
|
||||
(quickcheck)
|
||||
(quickcheck arbitrary)
|
||||
(quickcheck property)
|
||||
(srfi srfi-26)
|
||||
(srfi srfi-64))
|
||||
|
||||
(define $integers ($list $integer))
|
||||
|
||||
(define ensure-min-priority-queue-order
|
||||
(property
|
||||
((integers $integers))
|
||||
(let ((q (make-priority-queue #:cmp <)))
|
||||
(for-each (cute pq-push! q <>) integers)
|
||||
(equal? (pq-drain! q) (sort integers <)))))
|
||||
|
||||
(define ensure-min-abs-priority-queue-order
|
||||
(property
|
||||
((integers $integers))
|
||||
(let ((q (make-priority-queue #:cmp < #:priority abs)))
|
||||
(for-each (cute pq-push! q <>) integers)
|
||||
;; Can't use equal? for this test as two elements with the same absolute
|
||||
;; value might appear in a different order.
|
||||
(sorted? (pq-drain! q) (lambda (x y) (< (abs x) (abs y)))))))
|
||||
|
||||
(define ensure-max-priority-queue-order
|
||||
(property
|
||||
((integers $integers))
|
||||
(let ((q (make-priority-queue #:cmp >)))
|
||||
(for-each (cute pq-push! q <>) integers)
|
||||
(equal? (pq-drain! q) (sort integers >)))))
|
||||
|
||||
(define ensure-max-abs-priority-queue-order
|
||||
(property
|
||||
((integers $integers))
|
||||
(let ((q (make-priority-queue #:cmp > #:priority abs)))
|
||||
(for-each (cute pq-push! q <>) integers)
|
||||
;; Can't use equal? for this test as two elements with the same absolute
|
||||
;; value might appear in a different order.
|
||||
(sorted? (pq-drain! q) (lambda (x y) (> (abs x) (abs y)))))))
|
||||
|
||||
(test-begin "min-priority-queue-order")
|
||||
|
||||
(quickcheck ensure-min-priority-queue-order)
|
||||
|
||||
(test-end "min-priority-queue-order")
|
||||
|
||||
(test-begin "max-priority-queue-order")
|
||||
|
||||
(quickcheck ensure-max-priority-queue-order)
|
||||
|
||||
(test-end "max-priority-queue-order")
|
||||
|
||||
(test-begin "min-abs-priority-queue-order")
|
||||
|
||||
(quickcheck ensure-min-abs-priority-queue-order)
|
||||
|
||||
(test-end "min-abs-priority-queue-order")
|
||||
|
||||
(test-begin "max-abs-priority-queue-order")
|
||||
(quickcheck ensure-max-abs-priority-queue-order)
|
||||
(test-end "max-abs-priority-queue-order")
|
Loading…
Add table
Add a link
Reference in a new issue