OSDN Git Service

* Added link tag for CHTML1.0 converter.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Mon, 23 Jun 2008 11:35:18 +0000 (11:35 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Mon, 23 Jun 2008 11:35:18 +0000 (11:35 +0000)
  * Added test of the link tag for CHTML1.0 converter.

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/sandbox@2723 1a406e8e-add9-4483-a2c8-d8cac5b7c224

src/chxj_chtml10.c
test/chxj_chtml10/test_chxj_chtml10.c

index bb84031..6bfca85 100644 (file)
@@ -3256,25 +3256,16 @@ s_chtml10_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
 
 
 /**
-<<<<<<< HEAD:src/chxj_chtml10.c
  * It is a handler who processes the LINK tag.
  *
  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
  *                     destination is specified.
  * @param node   [i]   The LINK tag node is specified.
  * @return The conversion result is returned.
-=======
- * It is handler who processes the New Line Code.
->>>>>>> master:src/chxj_chtml10.c
  */
 static char *
-<<<<<<< HEAD:src/chxj_chtml10.c
 s_chtml10_link_tag(void *pdoc, Node *node)
-=======
-s_chtml10_newline_mark(void *pdoc, Node *UNUSED(node))
->>>>>>> master:src/chxj_chtml10.c
 {
-<<<<<<< HEAD:src/chxj_chtml10.c
   chtml10_t     *chtml10;
   Doc           *doc;
   Attr          *attr;
@@ -3365,12 +3356,16 @@ s_chtml10_style_tag(void *pdoc, Node *node)
       DBG(doc->r, "end load CSS. value:[%s]", value);
     }
   }
+  return chtml10->out;
+}
+
 
-=======
+static char *
+s_chtml10_newline_mark(void *pdoc, Node *UNUSED(node))
+{
   chtml10_t *chtml10 = GET_CHTML10(pdoc);
   Doc *doc = chtml10->doc;
   W_NLCODE();
->>>>>>> master:src/chxj_chtml10.c
   return chtml10->out;
 }
 /*
index a2280b0..18ff9a0 100644 (file)
@@ -419,7 +419,15 @@ void test_chtml10_font_tag_002();
 void test_chtml10_font_tag_003(); 
 
 /* CSS */
-void test_chtml10_css_001();
+void test_chtml10_link_001();
+void test_chtml10_link_002();
+void test_chtml10_link_003();
+void test_chtml10_link_004();
+void test_chtml10_link_005();
+void test_chtml10_link_006();
+void test_chtml10_link_007();
+void test_chtml10_link_008();
+void test_chtml10_link_009();
 /* pend */
 
 int
@@ -802,8 +810,15 @@ main()
 
 
   /* CSS */
-  CU_add_test(chtml10_suite, "test css 001." ,                                    test_chtml10_css_001); 
-
+  CU_add_test(chtml10_suite, "test link 001." ,                                    test_chtml10_link_001); 
+  CU_add_test(chtml10_suite, "test link 002." ,                                    test_chtml10_link_002); 
+  CU_add_test(chtml10_suite, "test link 003." ,                                    test_chtml10_link_003); 
+  CU_add_test(chtml10_suite, "test link 004." ,                                    test_chtml10_link_004); 
+  CU_add_test(chtml10_suite, "test link 005." ,                                    test_chtml10_link_005); 
+  CU_add_test(chtml10_suite, "test link 006." ,                                    test_chtml10_link_006); 
+  CU_add_test(chtml10_suite, "test link 007." ,                                    test_chtml10_link_007); 
+  CU_add_test(chtml10_suite, "test link 008." ,                                    test_chtml10_link_008); 
+  CU_add_test(chtml10_suite, "test link 009." ,                                    test_chtml10_link_009); 
   /* aend */
 
   CU_basic_run_tests();
@@ -10388,6 +10403,8 @@ void test_chtml10_font_tag_003()
 #undef RESULT_STRING
 }
 
+
+static int call_check = 0;
 char *test_chxj_serf_get001(request_rec *r, apr_pool_t *ppool, const char *uri_path)
 {
   static char *css = "a:focus { display: none }\n"
@@ -10396,12 +10413,261 @@ char *test_chxj_serf_get001(request_rec *r, apr_pool_t *ppool, const char *uri_p
                      "hr      { display: none }\n"
                      "a:visited { display:none }";
 
+  call_check = 1;
   return css;
 }
-void test_chtml10_css_001() 
+void test_chtml10_link_001() 
 {
 #define  TEST_STRING "<link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />"
-#define  RESULT_STRING "ハンカク"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+
+  call_check = 0;
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 1);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_002() 
+{
+#define  TEST_STRING "<link rel=\"abc\" href=\"http://localhost/a.css\" type=\"text/css\" />"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 0);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_003() 
+{
+#define  TEST_STRING "<link rel=\"\" href=\"http://localhost/a.css\" type=\"text/css\" />"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 0);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_004() 
+{
+#define  TEST_STRING "<link rel href=\"http://localhost/a.css\" type=\"text/css\" />"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 0);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_005() 
+{
+#define  TEST_STRING "<link rel=\"stylesheet\" href=\"\" type=\"text/css\" />"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 0);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_006() 
+{
+#define  TEST_STRING "<link rel=\"stylesheet\" href type=\"text/css\" />"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 0);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_007() 
+{
+#define  TEST_STRING "<link rel=\"stylesheet\" href=\"http://localhost/a.css\"  type=\"\" />"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 0);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_008() 
+{
+#define  TEST_STRING "<link rel=\"stylesheet\" href=\"http://localhost/a.css\"  type />"
+#define  RESULT_STRING "\n"
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+  chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_chtml10(&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);
+  CU_ASSERT(call_check == 0);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
+void test_chtml10_link_009() 
+{
+#define  TEST_STRING "<link rel=\"stylesheet\" href=\"http://localhost/a.css\"  type=\"text/abc\" />"
+#define  RESULT_STRING "\n"
   char  *ret;
   char  *tmp;
   device_table spec;
@@ -10410,6 +10676,7 @@ void test_chtml10_css_001()
   apr_size_t destlen;
   APR_INIT;
   chxj_serf_get = test_chxj_serf_get001;
+  call_check = 0;
 
   COOKIE_INIT(cookie);
 
@@ -10422,6 +10689,7 @@ void test_chtml10_css_001()
   CU_ASSERT(ret != NULL);
   CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
   CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+  CU_ASSERT(call_check == 0);
 
   APR_TERM;
 #undef TEST_STRING