| | #include "unity/unity.h" |
| | #include <libxml/HTMLparser.h> |
| | #include <string.h> |
| | #include <stdlib.h> |
| |
|
| | |
| | extern int test_htmlCompareStartClose(const void *vkey, const void *member); |
| |
|
| | |
| | |
| | typedef struct { |
| | const char *oldTag; |
| | const char *newTag; |
| | } TestEntry; |
| |
|
| | static int call_compare(const char *keyOld, const char *keyNew, |
| | const char *entOld, const char *entNew) { |
| | TestEntry key = { keyOld, keyNew }; |
| | TestEntry ent = { entOld, entNew }; |
| | return test_htmlCompareStartClose((const void *)&key, (const void *)&ent); |
| | } |
| |
|
| | void setUp(void) { |
| | |
| | } |
| |
|
| | void tearDown(void) { |
| | |
| | } |
| |
|
| | void test_htmlCompareStartClose_equal_old_and_new(void) { |
| | int ret = call_compare("div", "span", "div", "span"); |
| | TEST_ASSERT_EQUAL_INT(0, ret); |
| | } |
| |
|
| | void test_htmlCompareStartClose_different_old_less(void) { |
| | |
| | int ret = call_compare("a", "x", "b", "x"); |
| | TEST_ASSERT_TRUE(ret < 0); |
| | } |
| |
|
| | void test_htmlCompareStartClose_different_old_greater(void) { |
| | |
| | int ret = call_compare("span", "x", "div", "x"); |
| | TEST_ASSERT_TRUE(ret > 0); |
| | } |
| |
|
| | void test_htmlCompareStartClose_same_old_different_new_less(void) { |
| | |
| | int ret = call_compare("p", "a", "p", "b"); |
| | TEST_ASSERT_TRUE(ret < 0); |
| | } |
| |
|
| | void test_htmlCompareStartClose_same_old_different_new_greater(void) { |
| | |
| | int ret = call_compare("p", "z", "p", "y"); |
| | TEST_ASSERT_TRUE(ret > 0); |
| | } |
| |
|
| | void test_htmlCompareStartClose_prefix_oldtag_less(void) { |
| | |
| | int ret = call_compare("div", "x", "diva", "x"); |
| | TEST_ASSERT_TRUE(ret < 0); |
| | } |
| |
|
| | void test_htmlCompareStartClose_prefix_newtag_less(void) { |
| | |
| | int ret = call_compare("tag", "div", "tag", "diva"); |
| | TEST_ASSERT_TRUE(ret < 0); |
| | } |
| |
|
| | void test_htmlCompareStartClose_case_sensitivity_in_oldtag(void) { |
| | |
| | int ret = call_compare("Div", "x", "div", "x"); |
| | TEST_ASSERT_TRUE(ret < 0); |
| | } |
| |
|
| | void test_htmlCompareStartClose_case_sensitivity_in_newtag(void) { |
| | |
| | int ret = call_compare("tag", "Anchor", "tag", "anchor"); |
| | TEST_ASSERT_TRUE(ret < 0); |
| | } |
| |
|
| | int main(void) { |
| | UNITY_BEGIN(); |
| | RUN_TEST(test_htmlCompareStartClose_equal_old_and_new); |
| | RUN_TEST(test_htmlCompareStartClose_different_old_less); |
| | RUN_TEST(test_htmlCompareStartClose_different_old_greater); |
| | RUN_TEST(test_htmlCompareStartClose_same_old_different_new_less); |
| | RUN_TEST(test_htmlCompareStartClose_same_old_different_new_greater); |
| | RUN_TEST(test_htmlCompareStartClose_prefix_oldtag_less); |
| | RUN_TEST(test_htmlCompareStartClose_prefix_newtag_less); |
| | RUN_TEST(test_htmlCompareStartClose_case_sensitivity_in_oldtag); |
| | RUN_TEST(test_htmlCompareStartClose_case_sensitivity_in_newtag); |
| | return UNITY_END(); |
| | } |