From: kaoru Date: Thu, 19 Feb 2004 02:09:21 +0000 (+0000) Subject: * test-elmo-util.el (lunit-test-case-setup): Set `print-length', X-Git-Tag: wl-2_11_25~57 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b06bac91bbc694231af4a1834437de813ba8061;p=elisp%2Fwanderlust.git * test-elmo-util.el (lunit-test-case-setup): Set `print-length', `print-level', and `case-fold-search'. (lunit-test-case-teardown): Check file existence before remove. (test-elmo-object-save-2, test-elmo-save-string-1) (test-elmo-uniq-list-1, test-elmo-uniq-list-2) (test-elmo-uniq-list-delq) (test-elmo-list-insert-1, test-elmo-list-insert-2) (test-elmo-delete-char-1, test-elmo-concat-path-1) (test-elmo-remove-passwd-1): New testcases. --- diff --git a/tests/ChangeLog b/tests/ChangeLog index 2c6941f..1f4c68b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,15 @@ +2004-02-19 TAKAHASHI Kaoru + + * test-elmo-util.el (lunit-test-case-setup): Set `print-length', + `print-level', and `case-fold-search'. + (lunit-test-case-teardown): Check file existence before remove. + (test-elmo-object-save-2, test-elmo-save-string-1) + (test-elmo-uniq-list-1, test-elmo-uniq-list-2) + (test-elmo-uniq-list-delq) + (test-elmo-list-insert-1, test-elmo-list-insert-2) + (test-elmo-delete-char-1, test-elmo-concat-path-1) + (test-elmo-remove-passwd-1): New testcases. + 2004-02-18 TAKAHASHI Kaoru * test-elmo-util.el (test-elmo-object-save-1): New testcase. diff --git a/tests/test-elmo-util.el b/tests/test-elmo-util.el index 0bc877e..a7dc5e8 100644 --- a/tests/test-elmo-util.el +++ b/tests/test-elmo-util.el @@ -8,11 +8,15 @@ (defvar test-elmo-temoporary-file) (luna-define-method lunit-test-case-setup ((case test-elmo-util)) + (setq print-length 1 + print-level 1) + (setq case-fold-search nil) (setq test-elmo-temoporary-file (make-temp-file temporary-file-directory))) (luna-define-method lunit-test-case-teardown ((case test-elmo-util)) - (delete-file test-elmo-temoporary-file)) + (when (file-exists-p test-elmo-temoporary-file) + (delete-file test-elmo-temoporary-file))) (luna-define-method test-elmo-replace-string-as-filename-1 ((case test-elmo-util)) @@ -23,11 +27,96 @@ (elmo-replace-string-as-filename str)))))) +;; object save & load (luna-define-method test-elmo-object-save-1 ((case test-elmo-util)) - (let ((list '(1 2 3 4 5 6 7 8 9 10 11 12)) - (print-length 1) - (print-level 1)) + (let ((list '(1 2 3 4 5 6 7 8 9 10 11 12))) (elmo-object-save test-elmo-temoporary-file list) (lunit-assert (equal list (elmo-object-load test-elmo-temoporary-file))))) + +(luna-define-method test-elmo-object-save-2 ((case test-elmo-util)) + (let ((list '(1 (2 :foo (nil . :bar))))) + (elmo-object-save test-elmo-temoporary-file list) + (lunit-assert + (equal list + (elmo-object-load test-elmo-temoporary-file))))) + +(luna-define-method test-elmo-save-string-1 ((case test-elmo-util)) + ) + +;; list functions +(luna-define-method test-elmo-uniq-list-1 ((case test-elmo-util)) + (lunit-assert + (eq nil (elmo-uniq-list nil))) + (lunit-assert + (equal '(1) (elmo-uniq-list '(1)))) + (lunit-assert + (equal '(1) (elmo-uniq-list '(1 1)))) + (lunit-assert + (equal '(1) (elmo-uniq-list '(1 1 1))))) + +(luna-define-method test-elmo-uniq-list-2 ((case test-elmo-util)) + (lunit-assert + (equal '(1 2 3 4 5 6 nil) + (elmo-uniq-list '(1 2 3 4 1 5 6 nil nil 1 1 2)))) + (lunit-assert + (equal '("foo") (elmo-uniq-list '("foo" "foo"))))) + +(luna-define-method test-elmo-uniq-list-delq ((case test-elmo-util)) + (lunit-assert + (equal '("foo" "foo") (elmo-uniq-list '("foo" "foo") #'delq))) + (lunit-assert + (equal '(:foo) (elmo-uniq-list '(:foo :foo) #'delq)))) + +(luna-define-method test-elmo-list-insert-1 ((case test-elmo-util)) + (lunit-assert + (equal '(1 2 3 4 5) + (elmo-list-insert '(1 2 3 5) 4 3))) + (lunit-assert + (equal '(1 2 3 5 9) + (elmo-list-insert '(1 2 3 5) 9 :notfound))) +;;; memq vs. member +;;; (equal '(1 2 "3" 5 4) +;;; (elmo-list-insert '(1 2 "3" 5) 4 "3")) + ) + +(luna-define-method test-elmo-list-insert-2 ((case test-elmo-util)) + (let* ((list1 '(1 2 3 4 5)) + (list2 list1)) + (elmo-list-insert list1 4 3) + (lunit-assert + (eq list1 list2)))) +;;; memq vs. member +;;; (equal '(1 2 "3" 5 4) +;;; (elmo-list-insert '(1 2 "3" 5) 4 "3")) + +(luna-define-method test-elmo-delete-char-1 ((case test-elmo-util)) + (lunit-assert + (string= "f" (elmo-delete-char ?o "foo"))) + (lunit-assert + (string= "f\nf" (elmo-delete-char ?o "foo\nfoo"))) + (lunit-assert + (string= "" (elmo-delete-char ?o "oo"))) + (lunit-assert + (string= "" (elmo-delete-char ?o "")))) + +(luna-define-method test-elmo-concat-path-1 ((case test-elmo-util)) + (lunit-assert + (string= + "/home/foo" + (elmo-concat-path "/home" "foo"))) + (lunit-assert + (string= + (elmo-concat-path "/home/" "foo") + (elmo-concat-path "/home//" "foo")))) + + +(luna-define-method test-elmo-remove-passwd-1 ((case test-elmo-util)) + (let* ((password "cGFzc3dk") + (elmo-passwd-alist (list (cons "key" password)))) + (elmo-remove-passwd "key") + (lunit-assert + (string= "\0\0\0\0\0\0\0\0" password)) + (lunit-assert + (null elmo-passwd-alist))))