aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-02-24 23:38:38 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-02-24 23:38:38 +0000
commit02b87cdc9c5e5ad7e5a4618ed8131730911ed3da (patch)
treef6d9381ddd9a299aeebf521595ec24a14c953e62 /tests
parentac8860e1d71188badfb63c7fa678f1502455723d (diff)
downloadcantedraw-02b87cdc9c5e5ad7e5a4618ed8131730911ed3da.tar.gz
cantedraw-02b87cdc9c5e5ad7e5a4618ed8131730911ed3da.tar.bz2
cantedraw-02b87cdc9c5e5ad7e5a4618ed8131730911ed3da.zip
Implement test for suit->int
Diffstat (limited to 'tests')
-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")))
+