[uim-commit] r1994 - in trunk: scm test
yamaken at freedesktop.org
yamaken at freedesktop.org
Sat Nov 5 01:47:30 PST 2005
Author: yamaken
Date: 2005-11-05 01:47:27 -0800 (Sat, 05 Nov 2005)
New Revision: 1994
Modified:
trunk/scm/util.scm
trunk/test/test-util.scm
Log:
* test/test-util.scm
- (test string-escape): New test
* scm/util.scm
- (string-escape): Add brief description
Modified: trunk/scm/util.scm
===================================================================
--- trunk/scm/util.scm 2005-11-05 09:10:00 UTC (rev 1993)
+++ trunk/scm/util.scm 2005-11-05 09:47:27 UTC (rev 1994)
@@ -29,14 +29,26 @@
;;; SUCH DAMAGE.
;;;;
-;; Current uim implementation treats char as integer
-
-;; TODO: write test
+;; Make escaped string literal to print a form.
+;;
+;; (string-escape "a str\n") -> "\"a str\\n\""
+;;
+;; The following two codes must display same result. See
+;; test/test-util.scm for further specification.
+;;
+;; (display str)
+;;
+;; (use srfi-6)
+;; (define estr (string-append "(display " (string-escape str) ")"))
+;; (eval (read (open-input-string estr))
+;; (interaction-environment))
(define string-escape
(lambda (s)
(let ((buf (string-append "\"\"" s s)))
(print-to-string s buf))))
+;; Current uim implementation treats char as integer
+
;; TODO: write test
(define string->char
(lambda (str)
Modified: trunk/test/test-util.scm
===================================================================
--- trunk/test/test-util.scm 2005-11-05 09:10:00 UTC (rev 1993)
+++ trunk/test/test-util.scm 2005-11-05 09:47:27 UTC (rev 1994)
@@ -542,6 +542,60 @@
(uim '(string-append-map car '(("c" "C") ("a" "A") ("r" "R")))))))
(define-uim-test-case "testcase util misc"
+ ("test string-escape"
+ ;; empty string
+ (assert-equal "\"\""
+ (uim '(string-escape "")))
+ ;; single character
+ (assert-equal "\"\\\"\""
+ (uim '(string-escape "\"")))
+ (assert-equal "\"\\\\\""
+ (uim '(string-escape "\\")))
+ (assert-equal "\"\\n\""
+ (uim '(string-escape "\n")))
+ (assert-equal "\"a\""
+ (uim '(string-escape "a")))
+ (assert-equal "\"b\""
+ (uim '(string-escape "b")))
+ (assert-equal "\"c\""
+ (uim '(string-escape "c")))
+ (assert-equal "\"a\""
+ (uim '(string-escape "\a")))
+ (assert-equal "\"b\""
+ (uim '(string-escape "\b")))
+ (assert-equal "\"c\""
+ (uim '(string-escape "\c")))
+ (assert-equal "\"A\""
+ (uim '(string-escape "A")))
+ (assert-equal "\"B\""
+ (uim '(string-escape "B")))
+ (assert-equal "\"C\""
+ (uim '(string-escape "C")))
+ (assert-equal "\"A\""
+ (uim '(string-escape "\A")))
+ (assert-equal "\"B\""
+ (uim '(string-escape "\B")))
+ (assert-equal "\"C\""
+ (uim '(string-escape "\C")))
+ ;; 2 characters
+ (assert-equal "\"\\\"\\\"\""
+ (uim '(string-escape "\"\"")))
+ (assert-equal "\"\\\\\\\"\""
+ (uim '(string-escape "\\\"")))
+ (assert-equal "\"\\\\\\\\\""
+ (uim '(string-escape "\\\\")))
+ (assert-equal "\"\\r\\n\""
+ (uim '(string-escape "\r\n")))
+ (assert-equal "\"aB\""
+ (uim '(string-escape "aB")))
+ (assert-equal "\"aB\""
+ (uim '(string-escape "a\B")))
+ (assert-equal "\"aB\""
+ (uim '(string-escape "\a\B")))
+ ;; complex
+ (assert-equal "\"\\\"a string\\\" in two-line\\nstring\\n\""
+ (uim '(string-escape "\"a\ string\" in two-line\nstring\n"))))
+
("test compose"
(uim '(define test-list '(0 1 2 3 4 5)))
(assert-true (uim-bool '(procedure? (compose))))
More information about the uim-commit
mailing list