fix xml parser issue and the xml unit test

This commit is contained in:
Arvid Norberg 2012-02-27 07:02:11 +00:00
parent 30d02f6b7a
commit 6144280fde
2 changed files with 5 additions and 1 deletions

View File

@ -192,9 +192,12 @@ namespace libtorrent
// instead of a series of key value pairs
if (i == tag_end)
{
char tmp = *i;
*i = 0; // null terminate the content string
token = xml_tag_content;
val_start = 0;
callback(token, start, val_start);
*i = tmp;
break;
}

View File

@ -119,6 +119,7 @@ void parser_callback(std::string& out, int token, char const* s, char const* val
case xml_string: out += "S"; break;
case xml_attribute: out += "A"; break;
case xml_parse_error: out += "P"; break;
case xml_tag_content: out += "T"; break;
default: TEST_CHECK(false);
}
out += s;
@ -1345,7 +1346,7 @@ int test_main()
xml_parse(xml4, xml4 + sizeof(xml4) - 1, boost::bind(&parser_callback
, boost::ref(out4), _1, _2, _3));
std::cerr << out4 << std::endl;
TEST_CHECK(out4 == "BaPgarbage inside element bracketsSfooFaPgarbage inside element brackets");
TEST_CHECK(out4 == "BaTfSfooFaTv ");
// test upnp xml parser