1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
(use gauche.test)
(test-start "scmail.util")
(use scmail.util)
(use scmail.config-core)
(use scmail.config)
(use scmail.progress)
(test-module 'scmail.util)
(test* "safe-rxmatch" #f
(safe-rxmatch #/abc/
(string-complete->incomplete "abcdefg")))
(test* "safe-rxmatch" #t
(regmatch? (safe-rxmatch #/abc/
"abcdefg")))
(test* "scmail-set-program-name!" #f
(scmail-set-program-name! "test"))
(with-module
scmail.util
(export get-last-line)
(define (exit . args)
(format #t "exit ~a" args))
(define output-port (open-output-string))
(define standard-error-port
(lambda () output-port))
(define (get-last-line)
(call-with-input-string (get-output-string output-port)
(lambda (iport)
(car (reverse (port->string-list iport)))))))
(test "scmail-wformat" #t
(lambda ()
(scmail-wformat "foo")
(string=? "test: foo"
(get-last-line))))
(test "scmail-dformat" #f
(lambda ()
(scmail-dformat "foo")
(string=? "test: debug: foo"
(get-last-line))))
(scmail-config-set-verbose-mode!)
(test "scmail-dformat" #t
(lambda ()
(scmail-dformat "foo")
(string=? "test: debug: foo"
(get-last-line))))
(test "scmail-eformat" #t
(lambda ()
(scmail-eformat "exit")
(string=? "test: exit"
(get-last-line))))
(test "scmail-eformat" #t
(lambda ()
(scmail-eformat "exit")
(string=? "test: exit"
(get-last-line))))
(test-end)
|