Trying to make test for `timeline-tools' independent of locale

This commit is contained in:
Daniel - 2020-01-05 14:28:31 +01:00
parent 243e579973
commit 4b7e02ccd6
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 74 additions and 69 deletions

View File

@ -202,8 +202,9 @@ CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
(ert-deftest timeline-tools-test-clockline-no-conflict-1 () (ert-deftest timeline-tools-test-clockline-no-conflict-1 ()
"Test `timeline-tools-clockline-no-conflict with complex example." "Test `timeline-tools-clockline-no-conflict with complex example."
(with-temp-buffer (let ((system-time-locale "C"))
(insert " (with-temp-buffer
(insert "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45 CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45
@ -233,13 +234,14 @@ CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
* Task 2 * Task 2
:LOGBOOK: :LOGBOOK:
:END: :END:
")))) ")))))
(ert-deftest timeline-tools-test-add-clockline-to-marker-1 () (ert-deftest timeline-tools-test-add-clockline-to-marker-1 ()
"Test `timeline-tools-add-clockline-to-marker without running "Test `timeline-tools-add-clockline-to-marker without running
clock." clock."
(with-temp-buffer (let ((system-time-locale "C"))
(insert " (with-temp-buffer
(insert "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45 CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45
@ -253,16 +255,16 @@ CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04
CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15 CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
:END: :END:
") ")
(org-mode) (org-mode)
(goto-char 216) (goto-char 216)
(let ((result (timeline-tools-add-clockline-to-marker (let ((result (timeline-tools-add-clockline-to-marker
(point-marker) (point-marker)
(org-time-string-to-seconds "[2018-01-07 Sun 13:00]") (org-time-string-to-seconds "[2018-01-07 Sun 13:00]")
(org-time-string-to-seconds "[2018-01-11 Thu 13:33]")))) (org-time-string-to-seconds "[2018-01-11 Thu 13:33]"))))
(should (null result)) (should (null result))
(should (equal (buffer-string) (should (equal (buffer-string)
" "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27 CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
@ -272,13 +274,14 @@ CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33 CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
:END: :END:
"))))) "))))))
(ert-deftest timeline-tools-test-add-clockline-to-marker-2 () (ert-deftest timeline-tools-test-add-clockline-to-marker-2 ()
"Test `timeline-tools-add-clockline-to-marker with running "Test `timeline-tools-add-clockline-to-marker with running
clock at same task." clock at same task."
(with-temp-buffer (let ((system-time-locale "C"))
(insert " (with-temp-buffer
(insert "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-10 Wed 10:07]--[2018-01-12 Fri 14:00] => 51:53 CLOCK: [2018-01-10 Wed 10:07]--[2018-01-12 Fri 14:00] => 51:53
@ -293,22 +296,22 @@ CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04 CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04
:END: :END:
") ")
(org-mode) (org-mode)
(let (;; simulate running clock at Task 2 (let (;; simulate running clock at Task 2
(org-clock-hd-marker (progn (goto-char 216) (point-marker))) (org-clock-hd-marker (progn (goto-char 216) (point-marker)))
(org-clock-marker (progn (goto-char 264) (point-marker))) (org-clock-marker (progn (goto-char 264) (point-marker)))
(org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]"))) (org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]")))
(let ((result (timeline-tools-add-clockline-to-marker (let ((result (timeline-tools-add-clockline-to-marker
org-clock-hd-marker org-clock-hd-marker
(org-time-string-to-seconds "[2018-01-07 Sun 13:00]") (org-time-string-to-seconds "[2018-01-07 Sun 13:00]")
(org-time-string-to-seconds "[2018-01-11 Thu 13:33]")))) (org-time-string-to-seconds "[2018-01-11 Thu 13:33]"))))
(should (null result)) (should (null result))
(should (equal org-clock-start-time (should (equal org-clock-start-time
(append (org-time-string-to-time "[2018-01-11 Thu 13:33]") (append (org-time-string-to-time "[2018-01-11 Thu 13:33]")
'(0 0)))) '(0 0))))
(should (equal (buffer-string) (should (equal (buffer-string)
" "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27 CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
@ -319,13 +322,14 @@ CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
CLOCK: [2018-01-11 Thu 13:33] CLOCK: [2018-01-11 Thu 13:33]
CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33 CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
:END: :END:
")))))) ")))))))
(ert-deftest timeline-tools-test-add-clockline-to-marker-3 () (ert-deftest timeline-tools-test-add-clockline-to-marker-3 ()
"Test `timeline-tools-add-clockline-to-marker with running "Test `timeline-tools-add-clockline-to-marker with running
clock at same task." clock at same task."
(with-temp-buffer (let ((system-time-locale "C"))
(insert " (with-temp-buffer
(insert "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-08 Mon 16:15]--[2018-01-10 Wed 13:10] => 44:55 CLOCK: [2018-01-08 Mon 16:15]--[2018-01-10 Wed 13:10] => 44:55
@ -339,22 +343,22 @@ CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04 CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04
:END: :END:
") ")
(org-mode) (org-mode)
(let (;; simulate running clock at Task 2 (let (;; simulate running clock at Task 2
(org-clock-hd-marker (progn (goto-char 153) (point-marker))) (org-clock-hd-marker (progn (goto-char 153) (point-marker)))
(org-clock-marker (progn (goto-char 201) (point-marker))) (org-clock-marker (progn (goto-char 201) (point-marker)))
(org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]"))) (org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]")))
(let ((result (timeline-tools-add-clockline-to-marker (let ((result (timeline-tools-add-clockline-to-marker
(progn (goto-char 2) (point-marker)) (progn (goto-char 2) (point-marker))
(org-time-string-to-seconds "[2018-01-07 Sun 13:00]") (org-time-string-to-seconds "[2018-01-07 Sun 13:00]")
(org-time-string-to-seconds "[2018-01-11 Thu 13:33]")))) (org-time-string-to-seconds "[2018-01-11 Thu 13:33]"))))
(should (null result)) (should (null result))
(should (equal org-clock-start-time (should (equal org-clock-start-time
(append (org-time-string-to-time "[2018-01-11 Thu 13:33]") (append (org-time-string-to-time "[2018-01-11 Thu 13:33]")
'(0 0)))) '(0 0))))
(should (equal (buffer-string) (should (equal (buffer-string)
" "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33 CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
@ -364,14 +368,15 @@ CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33] CLOCK: [2018-01-11 Thu 13:33]
:END: :END:
")))))) ")))))))
(ert-deftest timeline-tools-test-add-clockline-to-marker-4 () (ert-deftest timeline-tools-test-add-clockline-to-marker-4 ()
"Test `timeline-tools-add-clockline-to-marker with running "Test `timeline-tools-add-clockline-to-marker with running
clock at other task, and where afterwards only the running clock clock at other task, and where afterwards only the running clock
line is left." line is left."
(with-temp-buffer (let ((system-time-locale "C"))
(insert " (with-temp-buffer
(insert "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-10 Wed 10:07]--[2018-01-12 Fri 14:00] => 51:53 CLOCK: [2018-01-10 Wed 10:07]--[2018-01-12 Fri 14:00] => 51:53
@ -386,22 +391,22 @@ CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04 CLOCK: [2018-01-07 Sun 15:13]--[2018-01-07 Sun 16:17] => 1:04
:END: :END:
") ")
(org-mode) (org-mode)
(let (;; simulate running clock at Task 2 (let (;; simulate running clock at Task 2
(org-clock-hd-marker (progn (goto-char 216) (point-marker))) (org-clock-hd-marker (progn (goto-char 216) (point-marker)))
(org-clock-marker (progn (goto-char 264) (point-marker))) (org-clock-marker (progn (goto-char 264) (point-marker)))
(org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]"))) (org-clock-start-time (org-time-string-to-time "[2018-01-10 Wed 13:10]")))
(let ((result (timeline-tools-add-clockline-to-marker (let ((result (timeline-tools-add-clockline-to-marker
(progn (goto-char 2) (point-marker)) (progn (goto-char 2) (point-marker))
(org-time-string-to-seconds "[2018-01-07 Sun 13:00]") (org-time-string-to-seconds "[2018-01-07 Sun 13:00]")
(org-time-string-to-seconds "[2018-01-11 Thu 13:33]")))) (org-time-string-to-seconds "[2018-01-11 Thu 13:33]"))))
(should (null result)) (should (null result))
(should (equal org-clock-start-time (should (equal org-clock-start-time
(append (org-time-string-to-time "[2018-01-11 Thu 13:33]") (append (org-time-string-to-time "[2018-01-11 Thu 13:33]")
'(0 0)))) '(0 0))))
(should (equal (buffer-string) (should (equal (buffer-string)
" "
* Task 1 * Task 1
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33 CLOCK: [2018-01-07 Sun 13:00]--[2018-01-11 Thu 13:33] => 96:33
@ -412,6 +417,6 @@ CLOCK: [2018-01-11 Thu 13:33]--[2018-01-12 Fri 14:00] => 24:27
:LOGBOOK: :LOGBOOK:
CLOCK: [2018-01-11 Thu 13:33] CLOCK: [2018-01-11 Thu 13:33]
:END: :END:
")))))) ")))))))
;;; timeline-tools-test.el ends here ;;; timeline-tools-test.el ends here