emacs-ironsworn/rpgdm-ironsworn-tests.el
2022-02-26 11:32:14 -08:00

66 lines
4.4 KiB
EmacsLisp

(ert-deftest rpgdm-ironsworn--results-test ()
(should (equal (rpgdm-ironsworn--results 3 2 4 1)
"Strong hit :: 5 (3 + 2) → 4 / 1"))
(should (equal (rpgdm-ironsworn--results 3 2 8 1)
"Weak hit :: 5 (3 + 2) → 8 / 1"))
(should (equal (rpgdm-ironsworn--results 3 2 8 6)
"Miss :: 5 (3 + 2) → 8 / 6"))
(should (equal (rpgdm-ironsworn--results 3 2 6 6)
"Miss :: 5 (3 + 2) → 6 / 6 ← Create a Twist"))
(should (equal (rpgdm-ironsworn--results 3 2 8 6 7)
"Miss :: 5 (3 + 2) → 8 / 6 -- Burn momentum for a Weak hit"))
(should (equal (rpgdm-ironsworn--results 3 2 8 6 9)
"Miss :: 5 (3 + 2) → 8 / 6 -- Burn momentum for a Strong hit")))
(ert-deftest rpgdm-ironsworn--good-character-assets-test ()
(should (rpgdm-ironsworn--good-character-assets '("foo" "bar" "baz")))
(should-not (rpgdm-ironsworn--good-character-assets '("foo" "bar" "foo")))
(should-not (rpgdm-ironsworn--good-character-assets '("assets/companions/dog.org"
"assets/paths/good-guy.org"
"assets/companions/monkey.org")))
(should-not (rpgdm-ironsworn--good-character-assets '(("Companions :: Dog" . "assets/companions/dog.org")
("Paths :: Good Guy" . "assets/paths/good-guy.org")
("Companions :: Monkey" . "assets/companions/monkey.org")))))
(ert-deftest rpgdm-ironsworn--some-character-assets-test ()
(should (= 4 (seq-length (rpgdm-ironsworn--some-character-assets '(1 2 3 4 5 6) 4))))
(should (= 3 (seq-length (rpgdm-ironsworn--some-character-assets '(1 2 3 4 5 6))))))
(ert-deftest rpgdm-ironsworn--move-tuple-test ()
(let ((file "moves/fate/ask-the-oracle.org")
(full "~/other/over/here/moves/fate/ask-the-oracle.org"))
(should (equal (list "Fate :: ask the oracle" file)
(rpgdm-ironsworn--move-tuple file)))
(should (equal (list "Fate :: ask the oracle" full)
(rpgdm-ironsworn--move-tuple full)))))
(ert-deftest rpgdm-ironsworn-progress-level-label-test ()
(should (equal (rpgdm-ironsworn-progress-level-label 1) "epic"))
(should (equal (rpgdm-ironsworn-progress-level-label 12) "troublesome"))
(should (equal (rpgdm-ironsworn-progress-level-label 4) "formidable")))
(ert-deftest rpgdm-ironsworn--progress-box-test ()
(should (equal (rpgdm-ironsworn--progress-box 0 0) "| | | | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 0 1) "| - | | | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 0 2) "| x | | | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 0 3) "| * | | | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 1 0) "| ■ | | | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 2 0) "| ■ | ■ | | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 3 0) "| ■ | ■ | ■ | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 4 0) "| ■ | ■ | ■ | ■ | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 4 1) "| ■ | ■ | ■ | ■ | - | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 4 2) "| ■ | ■ | ■ | ■ | x | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 4 3) "| ■ | ■ | ■ | ■ | * | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 5 0) "| ■ | ■ | ■ | ■ | ■ | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 10 0) "| ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ |"))
;; Negative test cases
(should (equal (rpgdm-ironsworn--progress-box 11 0) "| ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ |"))
(should (equal (rpgdm-ironsworn--progress-box -1 0) "| | | | | | | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 4 8) "| ■ | ■ | ■ | ■ | ■ | ■ | | | | |"))
(should (equal (rpgdm-ironsworn--progress-box 4 6) "| ■ | ■ | ■ | ■ | ■ | x | | | | |")))
(ert-deftest rpgdm-ironsworn--progress-to-str-test ()
(should (equal (rpgdm-ironsworn--progress-to-str :IRONSWORN-PROGRESS-EPIC)
"ironsworn-progress-epic")))