aboutsummaryrefslogtreecommitdiff
path: root/tests/model.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/model.lisp')
-rw-r--r--tests/model.lisp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/model.lisp b/tests/model.lisp
index 359c6ee..dd0884e 100644
--- a/tests/model.lisp
+++ b/tests/model.lisp
@@ -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")))
+