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))
26 (let ((str "/foo//./../bar/"))
28 (elmo-recover-string-from-filename
29 (elmo-replace-string-as-filename str))))))
33 (luna-define-method test-elmo-object-save-1 ((case test-elmo-util))
34 (let ((list '(1 2 3 4 5 6 7 8 9 10 11 12)))
35 (elmo-object-save test-elmo-temoporary-file list)
38 (elmo-object-load test-elmo-temoporary-file)))))
40 (luna-define-method test-elmo-object-save-2 ((case test-elmo-util))
41 (let ((list '(1 (2 :foo (nil . :bar)))))
42 (elmo-object-save test-elmo-temoporary-file list)
45 (elmo-object-load test-elmo-temoporary-file)))))
47 (luna-define-method test-elmo-save-string-1 ((case test-elmo-util))
51 (luna-define-method test-elmo-uniq-list-1 ((case test-elmo-util))
53 (eq nil (elmo-uniq-list nil)))
55 (equal '(1) (elmo-uniq-list '(1))))
57 (equal '(1) (elmo-uniq-list '(1 1))))
59 (equal '(1) (elmo-uniq-list '(1 1 1)))))
61 (luna-define-method test-elmo-uniq-list-2 ((case test-elmo-util))
63 (equal '(1 2 3 4 5 6 nil)
64 (elmo-uniq-list '(1 2 3 4 1 5 6 nil nil 1 1 2))))
66 (equal '("foo") (elmo-uniq-list '("foo" "foo")))))
68 (luna-define-method test-elmo-uniq-list-delq ((case test-elmo-util))
70 (equal '("foo" "foo") (elmo-uniq-list '("foo" "foo") #'delq)))
72 (equal '(:foo) (elmo-uniq-list '(:foo :foo) #'delq))))
74 (luna-define-method test-elmo-list-insert-1 ((case test-elmo-util))
77 (elmo-list-insert '(1 2 3 5) 4 3)))
80 (elmo-list-insert '(1 2 3 5) 9 :notfound)))
82 ;;; (equal '(1 2 "3" 5 4)
83 ;;; (elmo-list-insert '(1 2 "3" 5) 4 "3"))
86 (luna-define-method test-elmo-list-insert-2 ((case test-elmo-util))
87 (let* ((list1 '(1 2 3 4 5))
89 (elmo-list-insert list1 4 3)
93 ;;; (equal '(1 2 "3" 5 4)
94 ;;; (elmo-list-insert '(1 2 "3" 5) 4 "3"))
96 (luna-define-method test-elmo-delete-char-1 ((case test-elmo-util))
98 (string= "f" (elmo-delete-char ?o "foo")))
100 (string= "f\nf" (elmo-delete-char ?o "foo\nfoo")))
102 (string= "" (elmo-delete-char ?o "oo")))
104 (string= "" (elmo-delete-char ?o ""))))
106 (luna-define-method test-elmo-concat-path-1 ((case test-elmo-util))
110 (elmo-concat-path "/home" "foo")))
113 (elmo-concat-path "/home/" "foo")
114 (elmo-concat-path "/home//" "foo"))))
117 (luna-define-method test-elmo-remove-passwd-1 ((case test-elmo-util))
118 (let* ((password "cGFzc3dk")
119 (elmo-passwd-alist (list (cons "key" password))))
120 (elmo-remove-passwd "key")
122 (string= "\0\0\0\0\0\0\0\0" password))
124 (null elmo-passwd-alist))))