[uim-commit] r1859 - in branches/r5rs/sigscheme: . test
jun0 at freedesktop.org
jun0 at freedesktop.org
Tue Oct 18 00:12:22 PDT 2005
Author: jun0
Date: 2005-10-18 00:12:15 -0700 (Tue, 18 Oct 2005)
New Revision: 1859
Added:
branches/r5rs/sigscheme/test/test-enc-eucgeneric.scm
branches/r5rs/sigscheme/test/test-enc-eucjp.scm
branches/r5rs/sigscheme/test/test-enc-sjis.scm
branches/r5rs/sigscheme/test/test-enc-utf8.scm
Modified:
branches/r5rs/sigscheme/encoding.c
Log:
Add unit tests. Fix bugs.
* sigscheme/encoding.c
- (eucjp_scan_char, euckr_scan_char, euccn_scan_char): Improve
space/del handling.
- (IS_GR_SPC_OR_DEL): New macro.
* sigscheme/test/test-enc-utf8.scm
- New unit test.
* sigscheme/test/test-enc-eucjp.scm
- New unit test.
* sigscheme/test/test-enc-sjis.scm
- New unit test.
* sigscheme/test/test-enc-eucgeneric.scm
- New unit test.
Modified: branches/r5rs/sigscheme/encoding.c
===================================================================
--- branches/r5rs/sigscheme/encoding.c 2005-10-18 06:45:18 UTC (rev 1858)
+++ branches/r5rs/sigscheme/encoding.c 2005-10-18 07:12:15 UTC (rev 1859)
@@ -183,6 +183,7 @@
#define IN_GR96(c) (0xA0 <= (uchar)(c) && (uchar)(c) <= 0xFF)
#define IS_ASCII(c) ((uchar)(c) <= 0x7F)
+#define IS_GR_SPC_OR_DEL(c) ((uchar)(c) == 0xA0 || (uchar)(c) == 0xFF)
#define ESC 0x1B
#define SO 0x0E
@@ -216,13 +217,15 @@
EXPECT_SIZE(2);
if (size < 2) RETURN_INCOMPLETE(1);
#if SCM_STRICT_ENCODING_CHECK
- if (!IN_GR94(str[1])) RETURN_ERROR();
+ if (!IN_GR96(str[1])) RETURN_ERROR();
#endif
RETURN(2);
} else if ((uchar)str[0] == SS3) {
EXPECT_SIZE(3);
#if SCM_STRICT_ENCODING_CHECK
if (size < 2) RETURN_INCOMPLETE(size);
+ if (IS_GR_SPC_OR_DEL(str[1]))
+ RETURN(2);
if (!IN_GR94(str[1])) RETURN_ERROR();
if (size < 3) RETURN_INCOMPLETE(size);
if (!IN_GR94(str[2])) RETURN_ERROR();
@@ -262,7 +265,7 @@
if (size < 2)
RETURN_INCOMPLETE(size);
#if SCM_STRICT_ENCODING_CHECK
- if (!IN_GR94(str[1]))
+ if (!IN_GR96(str[1]))
RETURN_ERROR();
#endif
RETURN(2);
@@ -296,7 +299,7 @@
if (size < 2)
RETURN_INCOMPLETE(size);
#if SCM_STRICT_ENCODING_CHECK
- if (!IN_GR94(str[1]))
+ if (!IN_GR96(str[1]))
RETURN_ERROR();
#endif
RETURN(2);
Added: branches/r5rs/sigscheme/test/test-enc-eucgeneric.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-enc-eucgeneric.scm 2005-10-18 06:45:18 UTC (rev 1858)
+++ branches/r5rs/sigscheme/test/test-enc-eucgeneric.scm 2005-10-18 07:12:15 UTC (rev 1859)
@@ -0,0 +1,23 @@
+(load "./test/unittest.scm")
+
+;; This file provides a fallback test unit for all EUC systems. It's
+;; just a copy of test-enc-eucjp.scm with EUCJP-specific character
+;; sequences removed, so some characters may be undefined in other EUC
+;; systems.
+(assert-equal? "string 1" "Èþ¿Í¤Ë¤Ï" (string #\Èþ #\¿Í #\¤Ë #\¤Ï))
+(assert-equal? "list->string 1" "3Æü¤Ç" (list->string '(#\3 #\Æü #\¤Ç)))
+(assert-equal? "string->list 1" '(#\¤¡ #\¤ #\¤ë) (string->list "¤¡¤¤ë"))
+
+(assert-equal? "string-ref 1" #\Êâ (string-ref "»õhiÊâÍÊâ" 3))
+(assert-equal? "make-string 1" "ÊâÊâÊâÊâÊâ" (make-string 5 #\Êâ))
+(assert-equal? "string-copy 1" "¶â¶ä¹á" (string-copy "¶â¶ä¹á"))
+(assert-equal? "string-set! 1" "¶â·Ë¶Ì" (string-set!
+ (string-copy "¶â·Ë¤È")
+ 2
+ #\¶Ì))
+
+(define str1 "¤¢¥ãah˽\\˽n!¡ù¡ý!")
+(define str1-list '(#\¤¢ #\¥ã #\a #\h #\˽ #\\ #\˽ #\n #\! #\¡ù #\¡ý #\!))
+
+(assert-equal? "string 2" str1 (apply string str1-list))
+(assert-equal? "list->string 2" str1-list (string->list str1))
Added: branches/r5rs/sigscheme/test/test-enc-eucjp.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-enc-eucjp.scm 2005-10-18 06:45:18 UTC (rev 1858)
+++ branches/r5rs/sigscheme/test/test-enc-eucjp.scm 2005-10-18 07:12:15 UTC (rev 1859)
@@ -0,0 +1,24 @@
+;; -*- euc-jp -*-
+(load "./test/unittest.scm")
+
+(assert-equal? "string 1" "Èþ¿Í¤Ë¤Ï" (string #\Èþ #\¿Í #\¤Ë #\¤Ï))
+(assert-equal? "list->string 1" "3Æü¤Ç" (list->string '(#\3 #\Æü #\¤Ç)))
+(assert-equal? "string->list 1" '(#\¤¡ #\¤ #\¤ë) (string->list "¤¡¤¤ë"))
+
+(assert-equal? "string-ref 1" #\Êâ (string-ref "»õhiÊâÍÊâ" 3))
+(assert-equal? "make-string 1" "ÊâÊâÊâÊâÊâ" (make-string 5 #\Êâ))
+(assert-equal? "string-copy 1" "¶â¶ä¹á" (string-copy "¶â¶ä¹á"))
+(assert-equal? "string-set! 1" "¶â·Ë¶Ì" (string-set!
+ (string-copy "¶â·Ë¤È")
+ 2
+ #\¶Ì))
+
+
+;; The character after ¡ù is from JIS X 0212. The one after ¡ý is
+;; from JIS X 0213 plane 2. This violates all known standards, but
+;; souldn't be a real problem.
+(define str1 "¤¢Ë¥ãah˽\\˽n!¡ùää¡ý¡¢!")
+(define str1-list '(#\¤¢ #\Ë #\¥ã #\a #\h #\˽ #\\ #\˽ #\n #\! #\¡ù #\ää #\¡ý #\¡¢ #\!))
+
+(assert-equal? "string 2" str1 (apply string str1-list))
+(assert-equal? "list->string 2" str1-list (string->list str1))
Added: branches/r5rs/sigscheme/test/test-enc-sjis.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-enc-sjis.scm 2005-10-18 06:45:18 UTC (rev 1858)
+++ branches/r5rs/sigscheme/test/test-enc-sjis.scm 2005-10-18 07:12:15 UTC (rev 1859)
@@ -0,0 +1,24 @@
+;; -*- euc-jp -*-
+(load "./test/unittest.scm")
+
+(assert-equal? "string 1" "Èþ¿Í¤Ë¤Ï" (string #\Èþ #\¿Í #\¤Ë #\¤Ï))
+(assert-equal? "list->string 1" "3Æü¤Ç" (list->string '(#\3 #\Æü #\¤Ç)))
+(assert-equal? "string->list 1" '(#\¤¡ #\¤ #\¤ë) (string->list "¤¡¤¤ë"))
+
+(assert-equal? "string-ref 1" #\Êâ (string-ref "»õhiÊâÍÊâ" 3))
+(assert-equal? "make-string 1" "ÊâÊâÊâÊâÊâ" (make-string 5 #\Êâ))
+(assert-equal? "string-copy 1" "¶â¶ä¹á" (string-copy "¶â¶ä¹á"))
+(assert-equal? "string-set! 1" "¶â·Ë¶Ì" (string-set!
+ (string-copy "¶â·Ë¤È")
+ 2
+ #\¶Ì))
+
+
+
+
+;; The character after ¡ù is in JIS X 0213 plane 2.
+(define str1 "¤¢Ë¥ãah˽\\˽n!!¡ù !")
+(define str1-list '(#\¤¢ #\Ë #\¥ã #\a #\h #\˽ #\\ #\˽ #\n #\! #\! #\¡ù #\ #\!))
+
+(assert-equal? "string 2" str1 (apply string str1-list))
+(assert-equal? "list->string 2" str1-list (string->list str1))
Added: branches/r5rs/sigscheme/test/test-enc-utf8.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-enc-utf8.scm 2005-10-18 06:45:18 UTC (rev 1858)
+++ branches/r5rs/sigscheme/test/test-enc-utf8.scm 2005-10-18 07:12:15 UTC (rev 1859)
@@ -0,0 +1,21 @@
+;; -*- euc-jp -*-
+(load "./test/unittest.scm")
+
+(assert-equal? "string 1" "ç¾äººã«ã¯" (string #\ç¾ #\人 #\ã« #\ã¯))
+(assert-equal? "list->string 1" "3æ¥ã§" (list->string '(#\3 #\æ¥ #\ã§)))
+(assert-equal? "string->list 1" '(#\ã #\ã #\ã) (string->list "ããã"))
+
+(assert-equal? "string-ref 1" #\æ© (string-ref "æ¯hiæ©ï¾æ©" 3))
+(assert-equal? "make-string 1" "æ©æ©æ©æ©æ©" (make-string 5 #\æ©))
+(assert-equal? "string-copy 1" "ééé¦" (string-copy "ééé¦"))
+(assert-equal? "string-set! 1" "éæ¡ç" (string-set!
+ (string-copy "éæ¡ã¨")
+ 2
+ #\ç))
+
+
+(define str1 "ãï¾ã£ahæ´\\æ´n!âé³â!")
+(define str1-list '(#\ã #\ï¾ #\㣠#\a #\h #\æ´ #\\ #\æ´ #\n #\! #\â #\é³ #\â #\!))
+
+(assert-equal? "string 2" str1 (apply string str1-list))
+(assert-equal? "list->string 2" str1-list (string->list str1))
More information about the uim-commit
mailing list