5 (luna-define-class test-elmo-util (lunit-test-case))
8 (defvar test-elmo-temoporary-file)
10 (luna-define-method lunit-test-case-setup ((case test-elmo-util))
13 (setq case-fold-search nil)
14 (setq test-elmo-temoporary-file
15 (make-temp-file temporary-file-directory)))
17 (luna-define-method lunit-test-case-teardown ((case test-elmo-util))
18 (setq print-length nil
20 (when (file-exists-p test-elmo-temoporary-file)
21 (delete-file test-elmo-temoporary-file)))
24 (luna-define-method test-elmo-replace-string-as-filename-1 ((case test-elmo-util))
25 "Revert checking replace and recover."
27 (let ((str "/foo//./../bar/"))
29 (elmo-recover-string-from-filename
30 (elmo-replace-string-as-filename str))))))
34 (luna-define-method test-elmo-object-save-1 ((case test-elmo-util))
35 "Check `print-length' let bindings."
36 (let ((list '(1 2 3 4 5 6 7 8 9 10 11 12))
38 (elmo-object-save test-elmo-temoporary-file list)
41 (elmo-object-load test-elmo-temoporary-file)))))
43 (luna-define-method test-elmo-object-save-2 ((case test-elmo-util))
44 "Check `print-level' let bindings."
45 (let ((list '(1 (2 :foo (nil . :bar))))
47 (elmo-object-save test-elmo-temoporary-file list)
50 (elmo-object-load test-elmo-temoporary-file)))))
52 (luna-define-method test-elmo-save-string-1 ((case test-elmo-util))
56 (luna-define-method test-elmo-uniq-list-1 ((case test-elmo-util))
58 (eq nil (elmo-uniq-list nil)))
60 (equal '(1) (elmo-uniq-list '(1))))
62 (equal '(1) (elmo-uniq-list '(1 1))))
64 (equal '(1) (elmo-uniq-list '(1 1 1)))))
66 (luna-define-method test-elmo-uniq-list-2 ((case test-elmo-util))
68 (equal '(1 2 3 4 5 6 nil)
69 (elmo-uniq-list '(1 2 3 4 1 5 6 nil nil 1 1 2))))
71 (equal '("foo") (elmo-uniq-list '("foo" "foo")))))
73 (luna-define-method test-elmo-uniq-list-3 ((case test-elmo-util))
74 "Check using DELETE-FUNCTION"
76 (equal '("foo" "foo") (elmo-uniq-list '("foo" "foo") #'delq)))
78 (equal '(:foo) (elmo-uniq-list '(:foo :foo) #'delq))))
80 (luna-define-method test-elmo-list-insert-1 ((case test-elmo-util))
83 (elmo-list-insert '(1 2 3 5) 4 3)))
86 (elmo-list-insert '(1 2 3 5) 9 :notfound)))
88 ;;; (equal '(1 2 "3" 5 4)
89 ;;; (elmo-list-insert '(1 2 "3" 5) 4 "3"))
92 (luna-define-method test-elmo-list-insert-2 ((case test-elmo-util))
94 (let* ((list1 '(1 2 3 4 5))
96 (elmo-list-insert list1 4 3)
100 ;;; (equal '(1 2 "3" 5 4)
101 ;;; (elmo-list-insert '(1 2 "3" 5) 4 "3"))
103 (luna-define-method test-elmo-delete-char-1 ((case test-elmo-util))
105 (string= "f" (elmo-delete-char ?o "foo")))
107 (string= "f\nf" (elmo-delete-char ?o "foo\nfoo")))
109 (string= "" (elmo-delete-char ?o "oo")))
111 (string= "" (elmo-delete-char ?o ""))))
113 (luna-define-method test-elmo-concat-path-1 ((case test-elmo-util))
117 (elmo-concat-path "/home" "foo")))
120 (elmo-concat-path "/home/" "foo")
121 (elmo-concat-path "/home//" "foo"))))
124 (luna-define-method test-elmo-remove-passwd-1 ((case test-elmo-util))
125 "Check shred password."
126 (let* ((password "cGFzc3dk")
127 (elmo-passwd-alist (list (cons "key" password))))
128 (elmo-remove-passwd "key")
130 (string= "\0\0\0\0\0\0\0\0" password))))
132 (luna-define-method test-elmo-remove-passwd-2 ((case test-elmo-util))
133 "Check remove target pair only. Not rassoc."
134 (let ((password "cGFzc3dk")
135 (elmo-passwd-alist '(("foo" . "key")
138 (elmo-remove-passwd "key")
140 (equal '(("foo" . "key")
142 elmo-passwd-alist))))
144 (luna-define-method test-elmo-remove-passwd-3 ((case test-elmo-util))
146 (let ((password "cGFzc3dk")
147 (elmo-passwd-alist '(("foo" . "key")
151 (elmo-remove-passwd "key")
153 (equal '(("foo" . "key")
155 elmo-passwd-alist))))
157 (luna-define-method test-elmo-passwd-alist-clear-1 ((case test-elmo-util))
158 "Check shred ALL password."
159 (let* ((password1 "cGFzc3dk")
160 (password2 (copy-sequence password1))
161 (elmo-passwd-alist (list (cons "key1" password1)
162 (cons "key2" password2))))
163 (elmo-passwd-alist-clear)
165 (string= "\0\0\0\0\0\0\0\0" password1))
167 (string= "\0\0\0\0\0\0\0\0" password2))))