Implement test for suit->int

This commit is contained in:
2025-02-24 23:38:38 +00:00
parent ac8860e1d7
commit 02b87cdc9c

View File

@@ -88,3 +88,18 @@
(mapcar #'length)
remove-duplicates
length)))))
(define-test (model-test suit->int)
:depends-on ((cantedraw/tests/macros ->>))
:compile-at :execute
(fail (suit->int nil))
(fail (suit->int "not a suit"))
(fail (suit->int :still-not-a-suit))
(fail (suit->int 42069))
;; Prove suits are mapped to unique positive integers
(let ((res (->> (list :diamonds :clubs :hearts :spades :joker)
(mapcar #'suit->int))))
(true (every #'integerp res) "All integers")
(true (every ($>> (<= 0)) res) "All positive")
(is equal (length res) (length (remove-duplicates res)) "Unique mapping")))