From 6cc5d8eda7a0a04c5308e76b8b4c9f449b9e9590 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Sat, 26 Feb 2022 11:32:14 -0800 Subject: [PATCH] Fixed the progress box tests --- README.org | 4 ++-- rpgdm-ironsworn-tests.el | 38 +++++++++++++++++++------------------- rpgdm-ironsworn.el | 40 ++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/README.org b/README.org index 4e9ea12..9d7dacb 100644 --- a/README.org +++ b/README.org @@ -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: -#+BEGIN_SRC emacs-lisp +#+BEGIN_SRC emacs-lisp :tangle rpgdm-ironsworn-tests.el (ert-deftest rpgdm-ironsworn--progress-box-test () (should (equal (rpgdm-ironsworn--progress-box 0 0) "| | | | | | | | | | |")) (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 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 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) "| ■ | ■ | ■ | ■ | * | | | | | |")) diff --git a/rpgdm-ironsworn-tests.el b/rpgdm-ironsworn-tests.el index bb03c0e..8e44a4a 100644 --- a/rpgdm-ironsworn-tests.el +++ b/rpgdm-ironsworn-tests.el @@ -40,25 +40,25 @@ (should (equal (rpgdm-ironsworn-progress-level-label 12) "troublesome")) (should (equal (rpgdm-ironsworn-progress-level-label 4) "formidable"))) -(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)))) +(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) diff --git a/rpgdm-ironsworn.el b/rpgdm-ironsworn.el index b7e0e50..c664f9a 100644 --- a/rpgdm-ironsworn.el +++ b/rpgdm-ironsworn.el @@ -612,26 +612,6 @@ For instance, with 4 boxes and 2 leftover tick marks, this will return: (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) "Display the progress made against a track, NAME." (interactive (list (rpgdm-ironsworn-progress-track-choose))) @@ -662,6 +642,26 @@ This value is compared to rolling two d10 challenge dice." (ignore-errors (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) "Return a randomly generated name for a dangerous site. The PLACE-TYPE is something like 'shadowfen or 'sea-cave,