|
|
#include "unity/unity.h" |
|
|
#include <libxml/HTMLparser.h> |
|
|
#include <string.h> |
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
extern int test_htmlCheckAutoClose(const xmlChar * newtag, const xmlChar * oldtag); |
|
|
|
|
|
void setUp(void) { |
|
|
|
|
|
} |
|
|
|
|
|
void tearDown(void) { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_p_closes_p(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"p", |
|
|
(const xmlChar *)"p")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_li_closes_li(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"li", |
|
|
(const xmlChar *)"li")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_option_closes_option(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"option", |
|
|
(const xmlChar *)"option")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_tr_closes_tr(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"tr", |
|
|
(const xmlChar *)"tr")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_td_closes_td(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"td", |
|
|
(const xmlChar *)"td")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_th_closes_th(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"th", |
|
|
(const xmlChar *)"th")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_td_closes_th_and_th_closes_td(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"td", |
|
|
(const xmlChar *)"th")); |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"th", |
|
|
(const xmlChar *)"td")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_dt_dd_cross_closures(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"dt", |
|
|
(const xmlChar *)"dd")); |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"dd", |
|
|
(const xmlChar *)"dt")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_div_closes_p(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, test_htmlCheckAutoClose((const xmlChar *)"div", |
|
|
(const xmlChar *)"p")); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_b_does_not_close_b(void) { |
|
|
TEST_ASSERT_EQUAL_INT(0, test_htmlCheckAutoClose((const xmlChar *)"b", |
|
|
(const xmlChar *)"b")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_span_does_not_close_p(void) { |
|
|
TEST_ASSERT_EQUAL_INT(0, test_htmlCheckAutoClose((const xmlChar *)"span", |
|
|
(const xmlChar *)"p")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_unknown_tags_return_zero(void) { |
|
|
TEST_ASSERT_EQUAL_INT(0, test_htmlCheckAutoClose((const xmlChar *)"customnew", |
|
|
(const xmlChar *)"customold")); |
|
|
TEST_ASSERT_EQUAL_INT(0, test_htmlCheckAutoClose((const xmlChar *)"custom", |
|
|
(const xmlChar *)"p")); |
|
|
} |
|
|
|
|
|
|
|
|
void test_htmlCheckAutoClose_p_does_not_close_div(void) { |
|
|
TEST_ASSERT_EQUAL_INT(0, test_htmlCheckAutoClose((const xmlChar *)"p", |
|
|
(const xmlChar *)"div")); |
|
|
} |
|
|
|
|
|
int main(void) { |
|
|
UNITY_BEGIN(); |
|
|
|
|
|
RUN_TEST(test_htmlCheckAutoClose_p_closes_p); |
|
|
RUN_TEST(test_htmlCheckAutoClose_li_closes_li); |
|
|
RUN_TEST(test_htmlCheckAutoClose_option_closes_option); |
|
|
RUN_TEST(test_htmlCheckAutoClose_tr_closes_tr); |
|
|
RUN_TEST(test_htmlCheckAutoClose_td_closes_td); |
|
|
RUN_TEST(test_htmlCheckAutoClose_th_closes_th); |
|
|
RUN_TEST(test_htmlCheckAutoClose_td_closes_th_and_th_closes_td); |
|
|
RUN_TEST(test_htmlCheckAutoClose_dt_dd_cross_closures); |
|
|
RUN_TEST(test_htmlCheckAutoClose_div_closes_p); |
|
|
|
|
|
RUN_TEST(test_htmlCheckAutoClose_b_does_not_close_b); |
|
|
RUN_TEST(test_htmlCheckAutoClose_span_does_not_close_p); |
|
|
RUN_TEST(test_htmlCheckAutoClose_unknown_tags_return_zero); |
|
|
RUN_TEST(test_htmlCheckAutoClose_p_does_not_close_div); |
|
|
|
|
|
return UNITY_END(); |
|
|
} |