Replace mwolson with me in the sftp upload rule.
[planner-el.git] / test / planner-test.el
blob6d713fcc2bbd0cf47c003c17576ce97ce8b3b2fe
1 ;;; Test cases for planner
2 ;;; Sacha Chua (sacha@free.net.ph)
4 ;; Just load this and complain loudly if there are any errors.
5 ;; It only tests a handful of functions right now.
7 (require 'muse-project)
8 (require 'planner)
10 (defun planner-test (test-name test-cases test-function)
11 (while test-cases
12 (apply test-function test-name (car test-cases))
13 (setq test-cases (cdr test-cases))))
15 (planner-test
16 "planner-task-info-from-string"
17 '(("2004.03.01" "#A0 _ Test this function"
18 ("2004.03.01" "A" "0" "_" "Test this function" nil nil nil "2004.03.01"))
19 ("2004.03.01" "#A0 _ Test this function (PlanPage)"
20 ("2004.03.01" "A" "0" "_" "Test this function" "PlanPage" "PlanPage" "PlanPage" "2004.03.01"))
21 ("2004.03.01" "#A0 _ Test this function ([[PlanPage]])"
22 ("2004.03.01" "A" "0" "_" "Test this function" "PlanPage" "[[PlanPage]]" "PlanPage" "2004.03.01"))
23 ("2004.03.01" "#A0 _ Test this function ([[SomePage][Really]])"
24 ("2004.03.01" "A" "0" "_" "Test this function" "SomePage" "[[SomePage][Really]]" "SomePage" "2004.03.01"))
25 ("2004.03.01" "#A0 _ Test this function (NotPlanPage) junk"
26 ("2004.03.01" "A" "0" "_" "Test this function (NotPlanPage) junk" nil nil nil "2004.03.01"))
27 ("2004.03.01" "#A0 _ Test this function (NotPlanPage) (PlanPage)"
28 ("2004.03.01" "A" "0" "_" "Test this function (NotPlanPage)" "PlanPage" "PlanPage" "PlanPage" "2004.03.01"))
29 ("PlanPage" "#A0 _ Test this function"
30 ("PlanPage" "A" "0" "_" "Test this function" nil nil "PlanPage" nil))
31 ("PlanPage" "#A0 _ Test this function (2004.03.01)"
32 ("PlanPage" "A" "0" "_" "Test this function" "2004.03.01" "2004.03.01" "PlanPage" "2004.03.01"))
33 ("PlanPage" "#A0 _ Test this function (2004.03.01) junk"
34 ("PlanPage" "A" "0" "_" "Test this function (2004.03.01) junk" nil nil "PlanPage" nil))
35 ("PlanPage" "#A0 _ Test this function (2004.03.02) (2004.03.01)"
36 ("PlanPage" "A" "0" "_" "Test this function (2004.03.02)" "2004.03.01" "2004.03.01" "PlanPage" "2004.03.01"))
37 ("PlanPage" "#B1 X Completed task"
38 ("PlanPage" "B" "1" "X" "Completed task" nil nil "PlanPage" nil))
39 ("PlanPage" "#B1 X Completed task "
40 ("PlanPage" "B" "1" "X" "Completed task" nil nil "PlanPage" nil))
41 ("2004.03.01" "#A _ No priority"
42 ("2004.03.01" "A" nil "_" "No priority" nil nil nil "2004.03.01")))
43 (lambda (test-name page-name string expected-result)
44 (let ((output (planner-task-info-from-string page-name string)))
45 (unless (equal output expected-result)
46 (error "%s: output %s expected %s"
47 test-name output expected-result)))))
50 (planner-test
51 "planner-format-task"
52 '(("2004.03.01" "#A0 _ Test this function"
53 ("2004.03.01" "A" "0" "_" "Test this function" nil nil nil "2004.03.01"))
54 ("2004.03.01" "#A0 _ Test this function (PlanPage)"
55 ("2004.03.01" "A" "0" "_" "Test this function" "PlanPage" "PlanPage" "PlanPage" "2004.03.01"))
56 ("2004.03.01" "#A0 _ Test this function (PlanPage)"
57 ("2004.03.01" "A" "0" "_" "Test this function" "PlanPage" "[[PlanPage]]" "PlanPage" "2004.03.01"))
58 ("2004.03.01" "#A0 _ Test this function ([[SomePage][Really]])"
59 ("2004.03.01" "A" "0" "_" "Test this function" "SomePage" "[[SomePage][Really]]" "SomePage" "2004.03.01"))
60 ("2004.03.01" "#A0 _ Test this function (NotPlanPage) junk"
61 ("2004.03.01" "A" "0" "_" "Test this function (NotPlanPage) junk" nil nil nil "2004.03.01"))
62 ("2004.03.01" "#A0 _ Test this function (NotPlanPage) (PlanPage)"
63 ("2004.03.01" "A" "0" "_" "Test this function (NotPlanPage)" "PlanPage" "PlanPage" "PlanPage" "2004.03.01"))
64 ("PlanPage" "#A0 _ Test this function"
65 ("PlanPage" "A" "0" "_" "Test this function" nil nil "PlanPage" nil))
66 ("PlanPage" "#A0 _ Test this function (2004.03.01)"
67 ("PlanPage" "A" "0" "_" "Test this function" "2004.03.01" "2004.03.01" "PlanPage" "2004.03.01"))
68 ("PlanPage" "#A0 _ Test this function (2004.03.01) junk"
69 ("PlanPage" "A" "0" "_" "Test this function (2004.03.01) junk" nil nil "PlanPage" nil))
70 ("PlanPage" "#A0 _ Test this function (2004.03.02) (2004.03.01)"
71 ("PlanPage" "A" "0" "_" "Test this function (2004.03.02)" "2004.03.01" "2004.03.01" "PlanPage" "2004.03.01"))
72 ("PlanPage" "#B1 X Completed task"
73 ("PlanPage" "B" "1" "X" "Completed task" nil nil "PlanPage" nil))
74 ("2004.03.01" "#A _ No priority"
75 ("2004.03.01" "A" nil "_" "No priority" nil nil nil "2004.03.01")))
76 (lambda (test-name page-name expected-result info)
77 (with-muse-project planner-project
78 (let ((output (planner-format-task info)))
79 (unless (equal output expected-result)
80 (error "%s: output %s expected %s"
81 test-name output expected-result))))))
83 (planner-test
84 "planner-install-extra-task-keybindings"
85 nil
86 (lambda (test-case)
87 (with-muse-project planner-project
88 (let ((temp (copy-keymap planner-mode-map)))
89 (planner-install-extra-task-keybindings)
90 (setq planner-mode-map temp)))))
92 (planner-test
93 "planner-strip-whitespace"
94 '(("Hello world" "Helloworld")
95 ("Hello too" "Hellotoo")
96 ("Hello\nthree" "Hellothree"))
97 (lambda (test-name string expected-result)
98 (let ((output (planner-strip-whitespace string)))
99 (unless (equal output expected-result)
100 (error "%s: output %s expected %s"
101 test-name output expected-result)))))
103 (provide 'planner-test)
104 ;;;_* Local emacs vars.
105 ;; Local variables:
106 ;; change-log-default-name: "../ChangeLog"
107 ;; End:
108 ;;; planner-test.el ends here