From: ueno Date: Mon, 6 Dec 2004 09:25:32 +0000 (+0000) Subject: Use setup/teardown. X-Git-Tag: riece-1_0_7~125 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=f1c6124eb9ee484bea534085929d2ecbe9b60dc2;p=elisp%2Friece.git Use setup/teardown. --- diff --git a/lisp/test/test-riece-log.el b/lisp/test/test-riece-log.el index ea03b55..aeeb256 100644 --- a/lisp/test/test-riece-log.el +++ b/lisp/test/test-riece-log.el @@ -12,29 +12,45 @@ (setq files (cdr files))) (delete-directory directory))) -(luna-define-method test-riece-log-flashback ((case test-riece-log)) - (let ((riece-log-directory - (expand-file-name (make-temp-name "test-riece-log") +(luna-define-method lunit-test-case-setup ((case test-riece-log)) + (setq riece-log-directory + (expand-file-name (make-temp-name "test-riece-log") (if (featurep 'xemacs) (temp-directory) - temporary-file-directory))) - riece-addons) - (unwind-protect - (let ((dir (expand-file-name "riece" riece-log-directory)) - (riece-log-flashback 2) - riece-log-directory-map) - (make-directory riece-log-directory) - (make-directory dir) - (write-region "03:14 a b c\n" nil - (expand-file-name "20380119.log" dir) t 0) - (write-region "03:14 1 2 3\n" nil - (expand-file-name "20380118.log" dir) t 0) - (lunit-assert-2 - case - (equal - "03:14 1 2 3 (2038/01/18)\n03:14 a b c (2038/01/19)\n" + temporary-file-directory)) + test-riece-log-directory + (expand-file-name "riece" riece-log-directory)) + (make-directory riece-log-directory) + (make-directory test-riece-log-directory) + (write-region "03:14 a b c\n03:15 a b c\n" nil + (expand-file-name "20380119.log" test-riece-log-directory) + t 0) + (write-region "03:14 1 2 3\n" nil + (expand-file-name "20380118.log" test-riece-log-directory) + t 0)) + +(luna-define-method lunit-test-case-teardown ((case test-riece-log)) + (test-riece-log-delete-directory riece-log-directory)) + +(luna-define-method test-riece-log-flashback-1 ((case test-riece-log)) + (let ((riece-log-flashback 3) + riece-log-directory-map) + (lunit-assert-2 + case + (equal + (concat "03:14 1 2 3 (2038/01/18)\n" + "03:14 a b c (2038/01/19)\n" + "03:15 a b c (2038/01/19)\n") + (with-temp-buffer + (riece-log-flashback (riece-make-identity "#riece" "")) + (buffer-string)))))) + +(luna-define-method test-riece-log-flashback-2 ((case test-riece-log)) + (let ((riece-log-flashback t) + riece-log-directory-map) + (lunit-assert-2 + case + (equal "" (with-temp-buffer (riece-log-flashback (riece-make-identity "#riece" "")) - (buffer-string))))) - (test-riece-log-delete-directory riece-log-directory)))) - + (buffer-string))))))