Fixed the progress box tests
This commit is contained in:
parent
3c43efdbba
commit
6cc5d8eda7
3 changed files with 41 additions and 41 deletions
|
@ -1025,7 +1025,7 @@ Make a progress to visual table of boxes. Not sure if this is very helpful or no
|
||||||
|
|
||||||
Some tests may make it clear how that function will look:
|
Some tests may make it clear how that function will look:
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp :tangle rpgdm-ironsworn-tests.el
|
||||||
(ert-deftest rpgdm-ironsworn--progress-box-test ()
|
(ert-deftest rpgdm-ironsworn--progress-box-test ()
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 0 0) "| | | | | | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 0 0) "| | | | | | | | | | |"))
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 0 1) "| - | | | | | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 0 1) "| - | | | | | | | | | |"))
|
||||||
|
@ -1034,7 +1034,7 @@ Some tests may make it clear how that function will look:
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 1 0) "| ■ | | | | | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 1 0) "| ■ | | | | | | | | | |"))
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 2 0) "| ■ | ■ | | | | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 2 0) "| ■ | ■ | | | | | | | | |"))
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 3 0) "| ■ | ■ | ■ | | | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 3 0) "| ■ | ■ | ■ | | | | | | | |"))
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 4 0) "| ■ | ■ | ■ | ■ | | | | | | |"
|
(should (equal (rpgdm-ironsworn--progress-box 4 0) "| ■ | ■ | ■ | ■ | | | | | | |"))
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 4 1) "| ■ | ■ | ■ | ■ | - | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 4 1) "| ■ | ■ | ■ | ■ | - | | | | | |"))
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 4 2) "| ■ | ■ | ■ | ■ | x | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 4 2) "| ■ | ■ | ■ | ■ | x | | | | | |"))
|
||||||
(should (equal (rpgdm-ironsworn--progress-box 4 3) "| ■ | ■ | ■ | ■ | * | | | | | |"))
|
(should (equal (rpgdm-ironsworn--progress-box 4 3) "| ■ | ■ | ■ | ■ | * | | | | | |"))
|
||||||
|
|
|
@ -40,25 +40,25 @@
|
||||||
(should (equal (rpgdm-ironsworn-progress-level-label 12) "troublesome"))
|
(should (equal (rpgdm-ironsworn-progress-level-label 12) "troublesome"))
|
||||||
(should (equal (rpgdm-ironsworn-progress-level-label 4) "formidable")))
|
(should (equal (rpgdm-ironsworn-progress-level-label 4) "formidable")))
|
||||||
|
|
||||||
(ert-deftest rpgdm-ironsworn-progress-test ()
|
(ert-deftest rpgdm-ironsworn--progress-box-test ()
|
||||||
(let ((track "Battling a Grue"))
|
(should (equal (rpgdm-ironsworn--progress-box 0 0) "| | | | | | | | | | |"))
|
||||||
(rpgdm-ironsworn-progress-delete track)
|
(should (equal (rpgdm-ironsworn--progress-box 0 1) "| - | | | | | | | | | |"))
|
||||||
(rpgdm-ironsworn-progress-create track "Dangerous")
|
(should (equal (rpgdm-ironsworn--progress-box 0 2) "| x | | | | | | | | | |"))
|
||||||
(should (= (rpgdm-ironsworn-progress-amount track) 0))
|
(should (equal (rpgdm-ironsworn--progress-box 0 3) "| * | | | | | | | | | |"))
|
||||||
(rpgdm-ironsworn-progress-mark track)
|
(should (equal (rpgdm-ironsworn--progress-box 1 0) "| ■ | | | | | | | | | |"))
|
||||||
(should (= (rpgdm-ironsworn-progress-amount track) 2))
|
(should (equal (rpgdm-ironsworn--progress-box 2 0) "| ■ | ■ | | | | | | | | |"))
|
||||||
(rpgdm-ironsworn-progress-mark track 2)
|
(should (equal (rpgdm-ironsworn--progress-box 3 0) "| ■ | ■ | ■ | | | | | | | |"))
|
||||||
(should (= (rpgdm-ironsworn-progress-amount track) 6))))
|
(should (equal (rpgdm-ironsworn--progress-box 4 0) "| ■ | ■ | ■ | ■ | | | | | | |"))
|
||||||
|
(should (equal (rpgdm-ironsworn--progress-box 4 1) "| ■ | ■ | ■ | ■ | - | | | | | |"))
|
||||||
(ert-deftest rpgdm-ironsworn-progress-test ()
|
(should (equal (rpgdm-ironsworn--progress-box 4 2) "| ■ | ■ | ■ | ■ | x | | | | | |"))
|
||||||
(let ((track "Battling an Extreme Grue"))
|
(should (equal (rpgdm-ironsworn--progress-box 4 3) "| ■ | ■ | ■ | ■ | * | | | | | |"))
|
||||||
(rpgdm-ironsworn-progress-delete track)
|
(should (equal (rpgdm-ironsworn--progress-box 5 0) "| ■ | ■ | ■ | ■ | ■ | | | | | |"))
|
||||||
(rpgdm-ironsworn-progress-create track "Extreme")
|
(should (equal (rpgdm-ironsworn--progress-box 10 0) "| ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ |"))
|
||||||
(should (= (rpgdm-ironsworn-progress-amount track) 0))
|
;; Negative test cases
|
||||||
(rpgdm-ironsworn-progress-mark track)
|
(should (equal (rpgdm-ironsworn--progress-box 11 0) "| ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ | ■ |"))
|
||||||
(should (= (rpgdm-ironsworn-progress-amount track) 0))
|
(should (equal (rpgdm-ironsworn--progress-box -1 0) "| | | | | | | | | | |"))
|
||||||
(rpgdm-ironsworn-progress-mark track 2)
|
(should (equal (rpgdm-ironsworn--progress-box 4 8) "| ■ | ■ | ■ | ■ | ■ | ■ | | | | |"))
|
||||||
(should (= (rpgdm-ironsworn-progress-amount track) 1))))
|
(should (equal (rpgdm-ironsworn--progress-box 4 6) "| ■ | ■ | ■ | ■ | ■ | x | | | | |")))
|
||||||
|
|
||||||
(ert-deftest rpgdm-ironsworn--progress-to-str-test ()
|
(ert-deftest rpgdm-ironsworn--progress-to-str-test ()
|
||||||
(should (equal (rpgdm-ironsworn--progress-to-str :IRONSWORN-PROGRESS-EPIC)
|
(should (equal (rpgdm-ironsworn--progress-to-str :IRONSWORN-PROGRESS-EPIC)
|
||||||
|
|
|
@ -612,26 +612,6 @@ For instance, with 4 boxes and 2 leftover tick marks, this will return:
|
||||||
|
|
||||||
(concat "|" (make-box boxes leftover blanks)))
|
(concat "|" (make-box boxes leftover blanks)))
|
||||||
|
|
||||||
(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 | | | | |")))
|
|
||||||
|
|
||||||
(defun rpgdm-ironsworn-progress-amount (name)
|
(defun rpgdm-ironsworn-progress-amount (name)
|
||||||
"Display the progress made against a track, NAME."
|
"Display the progress made against a track, NAME."
|
||||||
(interactive (list (rpgdm-ironsworn-progress-track-choose)))
|
(interactive (list (rpgdm-ironsworn-progress-track-choose)))
|
||||||
|
@ -662,6 +642,26 @@ This value is compared to rolling two d10 challenge dice."
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
(remhash name tracks))))
|
(remhash name tracks))))
|
||||||
|
|
||||||
|
(ert-deftest rpgdm-ironsworn-progress-test ()
|
||||||
|
(let ((track "Battling a Grue"))
|
||||||
|
(rpgdm-ironsworn-progress-delete track)
|
||||||
|
(rpgdm-ironsworn-progress-create track "Dangerous")
|
||||||
|
(should (= (rpgdm-ironsworn-progress-amount track) 0))
|
||||||
|
(rpgdm-ironsworn-progress-mark track)
|
||||||
|
(should (= (rpgdm-ironsworn-progress-amount track) 2))
|
||||||
|
(rpgdm-ironsworn-progress-mark track 2)
|
||||||
|
(should (= (rpgdm-ironsworn-progress-amount track) 6))))
|
||||||
|
|
||||||
|
(ert-deftest rpgdm-ironsworn-progress-test ()
|
||||||
|
(let ((track "Battling an Extreme Grue"))
|
||||||
|
(rpgdm-ironsworn-progress-delete track)
|
||||||
|
(rpgdm-ironsworn-progress-create track "Extreme")
|
||||||
|
(should (= (rpgdm-ironsworn-progress-amount track) 0))
|
||||||
|
(rpgdm-ironsworn-progress-mark track)
|
||||||
|
(should (= (rpgdm-ironsworn-progress-amount track) 0))
|
||||||
|
(rpgdm-ironsworn-progress-mark track 2)
|
||||||
|
(should (= (rpgdm-ironsworn-progress-amount track) 1))))
|
||||||
|
|
||||||
(defun rpgdm-ironsworn-oracle-site-name (&optional place-type)
|
(defun rpgdm-ironsworn-oracle-site-name (&optional place-type)
|
||||||
"Return a randomly generated name for a dangerous site.
|
"Return a randomly generated name for a dangerous site.
|
||||||
The PLACE-TYPE is something like 'shadowfen or 'sea-cave,
|
The PLACE-TYPE is something like 'shadowfen or 'sea-cave,
|
||||||
|
|
Loading…
Reference in a new issue