OSDN Git Service

* Added test code of the <dir> tag for CHTML2.0 converter.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Wed, 9 Apr 2008 09:09:02 +0000 (09:09 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Wed, 9 Apr 2008 09:09:02 +0000 (09:09 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/RELEASE_0_11_0@2060 1a406e8e-add9-4483-a2c8-d8cac5b7c224

src/chxj_chtml20.c
test/chxj_chtml10/test_chxj_chtml10.c
test/chxj_chtml20/test_chxj_chtml20.c

index b47e965..a8bcda7 100644 (file)
@@ -1807,15 +1807,7 @@ s_chtml20_start_li_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t *chtml20;
-  Doc *doc;
-  request_rec *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
-  W20_L("</li>");
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
   return chtml20->out;
 }
 
index 4d22193..c221757 100644 (file)
@@ -419,6 +419,7 @@ main()
 
   CU_add_test(chtml10_suite, "test <dir>.",                                       test_chtml10_dir_tag_001); 
   CU_add_test(chtml10_suite, "test <dir> with no <li>.",                          test_chtml10_dir_tag_002); 
+
   CU_add_test(chtml10_suite, "test <dl>.",                                        test_chtml10_dl_tag_001); 
   CU_add_test(chtml10_suite, "test <dt>.",                                        test_chtml10_dt_tag_001); 
   CU_add_test(chtml10_suite, "test <dt> with void value.",                        test_chtml10_dt_tag_002); 
index 76c8a1e..c2e84a5 100644 (file)
@@ -88,6 +88,9 @@ void test_chtml20_br_tag_006();
 void test_chtml20_br_tag_007();
 
 void test_chtml20_center_tag_001();
+
+void test_chtml20_dir_tag_001();
+void test_chtml20_dir_tag_002();
 /* pend */
 
 int
@@ -150,6 +153,9 @@ main()
   CU_add_test(chtml20_suite, "test <br> with clear attribute(unknown value).",    test_chtml20_br_tag_007);
 
   CU_add_test(chtml20_suite, "test <center>.",                                    test_chtml20_center_tag_001);
+
+  CU_add_test(chtml20_suite, "test <dir>.",                                       test_chtml20_dir_tag_001);
+  CU_add_test(chtml20_suite, "test <dir> with no <li>.",                          test_chtml20_dir_tag_002);
   /* aend */
 
   CU_basic_run_tests();
@@ -1580,6 +1586,62 @@ void test_chtml20_center_tag_001()
 #undef TEST_STRING
 #undef RESULT_STRING
 }
+void test_chtml20_dir_tag_001()
+{
+#define  TEST_STRING "<html><head></head><body><dir><li>あああ<li>いいい</dir></body></html>"
+#define  RESULT_STRING "<html><head></head><body><dir><li>あああ<li>いいい</dir></body></html>"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_exchange_chtml20(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+  ret = chxj_rencoding(&r, ret, &destlen);
+  CU_ASSERT(ret != NULL);
+  CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+  CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml20_dir_tag_002()
+{
+#define  TEST_STRING "<html><head></head><body><dir></dir></body></html>"
+#define  RESULT_STRING "<html><head></head><body><dir></dir></body></html>"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_exchange_chtml20(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+  ret = chxj_rencoding(&r, ret, &destlen);
+  CU_ASSERT(ret != NULL);
+  CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+  CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
 /*
  * vim:ts=2 et
  */