OSDN Git Service

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

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

index 4004307..6662dd8 100644 (file)
@@ -805,7 +805,7 @@ s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W20_L("</title>\r\n");
+  W20_L("</title>");
   return chtml20->out;
 }
 
index 3205377..0101f5a 100644 (file)
@@ -448,6 +448,7 @@ main()
 
   CU_add_test(chtml10_suite, "test <head>.",                                      test_chtml10_head_tag_001); 
   CU_add_test(chtml10_suite, "test <head> with value.",                           test_chtml10_head_tag_002); 
+
   CU_add_test(chtml10_suite, "test <h1>.",                                        test_chtml10_h1_tag_001); 
   CU_add_test(chtml10_suite, "test <h1> with value.",                             test_chtml10_h1_tag_002); 
   CU_add_test(chtml10_suite, "test <h1> with value(japanese).",                   test_chtml10_h1_tag_003); 
index 45f84f6..dccbb1f 100644 (file)
@@ -118,6 +118,8 @@ void test_chtml20_form_tag_007();
 void test_chtml20_form_tag_008();
 void test_chtml20_form_tag_009();
 
+void test_chtml20_head_tag_001();
+void test_chtml20_head_tag_002();
 /* pend */
 
 int
@@ -209,6 +211,9 @@ main()
   CU_add_test(chtml20_suite, "test <form action> with null cookie.",              test_chtml20_form_tag_007);
   CU_add_test(chtml20_suite, "test <form action> with other site .",              test_chtml20_form_tag_008);
   CU_add_test(chtml20_suite, "test <form action method>.",                        test_chtml20_form_tag_009);
+
+  CU_add_test(chtml20_suite, "test <head>.",                                      test_chtml20_head_tag_001);
+  CU_add_test(chtml20_suite, "test <head> with value.",                           test_chtml20_head_tag_002);
   /* aend */
 
   CU_basic_run_tests();
@@ -2304,6 +2309,65 @@ void test_chtml20_form_tag_009()
 #undef TEST_STRING
 #undef RESULT_STRING
 }
+/*============================================================================*/
+/* <HEAD>                                                                     */
+/*============================================================================*/
+void test_chtml20_head_tag_001()
+{
+#define  TEST_STRING "<html><head></head><body></body></html>"
+#define  RESULT_STRING "<html><head></head><body></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_head_tag_002()
+{
+#define  TEST_STRING "<html><head><title>あああ</title></head><body></body></html>"
+#define  RESULT_STRING "<html><head><title>あああ</title></head><body></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
  */