aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-02-21 14:21:50 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-02-21 14:24:29 +0000
commit62f92114ee2d69bfb46084cc960a5c182f32df94 (patch)
tree3b8683b8dc1697cb71b3988d1a23122d353604bc
parent4bb9173a4abb4ea17070ef7ec9d10656cc13f81a (diff)
downloadcantedraw-62f92114ee2d69bfb46084cc960a5c182f32df94.tar.gz
cantedraw-62f92114ee2d69bfb46084cc960a5c182f32df94.tar.bz2
cantedraw-62f92114ee2d69bfb46084cc960a5c182f32df94.zip
Add unit tests for model.int->suit
-rw-r--r--tests/model.lisp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/model.lisp b/tests/model.lisp
index 7ea41c6..0fd8be4 100644
--- a/tests/model.lisp
+++ b/tests/model.lisp
@@ -25,3 +25,21 @@
(define-test model-test
:depends-on ((cantedraw/tests/macros macro-test)
(cantedraw/tests/functions function-test)))
+
+(define-test (model-test int->suit)
+ :compile-at :execute
+ (fail (int->suit nil))
+ (fail (int->suit "Not a number"))
+ ;; Proving int->suit splits 0-51 perfectly between the 4 suits
+ (let ((mapping (rev-map #'int->suit (range 0 53))))
+ (is eq 5 (length mapping))
+ (let ((spades (alist-val :spades mapping))
+ (hearts (alist-val :hearts mapping))
+ (clubs (alist-val :clubs mapping))
+ (diamonds (alist-val :diamonds mapping))
+ (jokers (alist-val :joker mapping)))
+ (is eq 1 (length jokers))
+ (is eq 1 (->> (list spades hearts clubs diamonds)
+ (mapcar #'length)
+ remove-duplicates
+ length)))))