diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-02-24 23:37:24 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-02-24 23:37:24 +0000 |
commit | aa2fa546745518c8c9119d7f0c10353f8d70abc1 (patch) | |
tree | 427addf0646c55bc4491a9568aa0415b4efac55c /tests/model.lisp | |
parent | b26c06fff326f61fa1d0885c5d5ff4bac77e3329 (diff) | |
download | cantedraw-aa2fa546745518c8c9119d7f0c10353f8d70abc1.tar.gz cantedraw-aa2fa546745518c8c9119d7f0c10353f8d70abc1.tar.bz2 cantedraw-aa2fa546745518c8c9119d7f0c10353f8d70abc1.zip |
Implement test for int->rank
Diffstat (limited to 'tests/model.lisp')
-rw-r--r-- | tests/model.lisp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/model.lisp b/tests/model.lisp index 32933ba..76924ca 100644 --- a/tests/model.lisp +++ b/tests/model.lisp @@ -23,6 +23,27 @@ (define-test model-test) +(define-test (model-test int->rank) + :depends-on ((cantedraw/tests/macros ->>) + (cantedraw/tests/functions rev-map)) + :compile-at :execute + (fail (int->rank nil)) + (fail (int->rank "Not a number")) + ;; Proving int->rank maps 0-51 to produces 13 ranks, all equally distributed. + (let ((mapping (rev-map #'int->rank (range 0 52)))) + ;; Prove there are 13 ranks + (is eq 13 (length mapping)) + ;; Prove every rank is equivalent in length. + (is eq 1 (->> mapping + (mapcar ($>> cdr length)) + remove-duplicates + length)) + ;; Prove Ace, 2, ..., 10, Jack, Queen, King are the 13 ranks. + (true (every #'identity + (->> (list :ace :king :queen :jack) + (append (range 2 11)) + (mapcar (lambda (rank) (assoc rank mapping)))))))) + (define-test (model-test int->suit) :depends-on ((cantedraw/tests/macros ->>) (cantedraw/tests/functions rev-map)) |