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 (when (file-exists-p test-elmo-temoporary-file)
19 (delete-file test-elmo-temoporary-file)))
22 (luna-define-method test-elmo-replace-string-as-filename-1 ((case test-elmo-util))
24 (let ((str "/foo//./../bar/"))
26 (elmo-recover-string-from-filename
27 (elmo-replace-string-as-filename str))))))
31 (luna-define-method test-elmo-object-save-1 ((case test-elmo-util))
32 (let ((list '(1 2 3 4 5 6 7 8 9 10 11 12)))
33 (elmo-object-save test-elmo-temoporary-file list)
36 (elmo-object-load test-elmo-temoporary-file)))))
38 (luna-define-method test-elmo-object-save-2 ((case test-elmo-util))
39 (let ((list '(1 (2 :foo (nil . :bar)))))
40 (elmo-object-save test-elmo-temoporary-file list)
43 (elmo-object-load test-elmo-temoporary-file)))))
45 (luna-define-method test-elmo-save-string-1 ((case test-elmo-util))
49 (luna-define-method test-elmo-uniq-list-1 ((case test-elmo-util))
51 (eq nil (elmo-uniq-list nil)))
53 (equal '(1) (elmo-uniq-list '(1))))
55 (equal '(1) (elmo-uniq-list '(1 1))))
57 (equal '(1) (elmo-uniq-list '(1 1 1)))))
59 (luna-define-method test-elmo-uniq-list-2 ((case test-elmo-util))
61 (equal '(1 2 3 4 5 6 nil)
62 (elmo-uniq-list '(1 2 3 4 1 5 6 nil nil 1 1 2))))
64 (equal '("foo") (elmo-uniq-list '("foo" "foo")))))
66 (luna-define-method test-elmo-uniq-list-delq ((case test-elmo-util))
68 (equal '("foo" "foo") (elmo-uniq-list '("foo" "foo") #'delq)))
70 (equal '(:foo) (elmo-uniq-list '(:foo :foo) #'delq))))
72 (luna-define-method test-elmo-list-insert-1 ((case test-elmo-util))
75 (elmo-list-insert '(1 2 3 5) 4 3)))
78 (elmo-list-insert '(1 2 3 5) 9 :notfound)))
80 ;;; (equal '(1 2 "3" 5 4)
81 ;;; (elmo-list-insert '(1 2 "3" 5) 4 "3"))
84 (luna-define-method test-elmo-list-insert-2 ((case test-elmo-util))
85 (let* ((list1 '(1 2 3 4 5))
87 (elmo-list-insert list1 4 3)
91 ;;; (equal '(1 2 "3" 5 4)
92 ;;; (elmo-list-insert '(1 2 "3" 5) 4 "3"))
94 (luna-define-method test-elmo-delete-char-1 ((case test-elmo-util))
96 (string= "f" (elmo-delete-char ?o "foo")))
98 (string= "f\nf" (elmo-delete-char ?o "foo\nfoo")))
100 (string= "" (elmo-delete-char ?o "oo")))
102 (string= "" (elmo-delete-char ?o ""))))
104 (luna-define-method test-elmo-concat-path-1 ((case test-elmo-util))
108 (elmo-concat-path "/home" "foo")))
111 (elmo-concat-path "/home/" "foo")
112 (elmo-concat-path "/home//" "foo"))))
115 (luna-define-method test-elmo-remove-passwd-1 ((case test-elmo-util))
116 (let* ((password "cGFzc3dk")
117 (elmo-passwd-alist (list (cons "key" password))))
118 (elmo-remove-passwd "key")
120 (string= "\0\0\0\0\0\0\0\0" password))
122 (null elmo-passwd-alist))))