#include "../kit/xml.h" #define KIT_TEST_FILE xml #include "../kit/kit_test.h" TEST("xml parse tag") { is_handle_t is = IS_WRAP_STRING(SZ(" ")); xml_parse_result_t res = xml_parse(is, NULL); REQUIRE_EQ(res.status, KIT_OK); if (res.status == KIT_OK) { REQUIRE(AR_EQUAL(res.xml.tag, SZ("foo"))); xml_destroy(&res.xml); } is_destroy(is); } TEST("xml parse tag not closed") { is_handle_t is = IS_WRAP_STRING(SZ("")); xml_parse_result_t res = xml_parse(is, NULL); REQUIRE_EQ(res.status, KIT_ERROR_INTERNAL); if (res.status == KIT_OK) xml_destroy(&res.xml); is_destroy(is); } TEST("xml parse tag text") { is_handle_t is = IS_WRAP_STRING(SZ(" bar ")); xml_parse_result_t res = xml_parse(is, NULL); REQUIRE_EQ(res.status, KIT_OK); if (res.status == KIT_OK) { REQUIRE(AR_EQUAL(res.xml.tag, SZ("foo"))); REQUIRE(AR_EQUAL(res.xml.text, SZ(" bar "))); xml_destroy(&res.xml); } is_destroy(is); } TEST("xml parse empty tag") { is_handle_t is = IS_WRAP_STRING(SZ("")); xml_parse_result_t res = xml_parse(is, NULL); REQUIRE_EQ(res.status, KIT_OK); if (res.status == KIT_OK) { REQUIRE(AR_EQUAL(res.xml.tag, SZ("foo"))); xml_destroy(&res.xml); } is_destroy(is); } #undef KIT_TEST_FILE