add asserts and attributes

Also remove extra trailing newlines at the end of the file.
This commit is contained in:
anonymous 2016-07-05 23:21:17 +02:00
parent 1533801fc8
commit 85bb6c20f8

View file

@ -2725,15 +2725,21 @@ EOS";
@system unittest @system unittest
{ {
string test_xml = `<?xml version="1.0" encoding='UTF-8'?><stream:stream string test_xml = `<?xml version="1.0" encoding='UTF-8'?><r><stream:stream
xmlns:stream="http://etherx.'jabber'.org/streams" xmlns:stream="http://etherx.'jabber'.org/streams"
xmlns="jabber:'client'" from='jid.pl' id="587a5767" xmlns="jabber:'client'" from='jid.pl' id="587a5767"
xml:lang="en" version="1.0"></stream:stream>`; xml:lang="en" version="1.0" attr='a"b"c'>
</stream:stream></r>`;
DocumentParser parser = new DocumentParser(test_xml); DocumentParser parser = new DocumentParser(test_xml);
parser.onStartTag["stream:stream"] = (ElementParser p) {
assert(p.tag.attr["xmlns"] == "jabber:'client'");
assert(p.tag.attr["from"] == "jid.pl");
assert(p.tag.attr["attr"] == "a\"b\"c");
};
} }
unittest @system unittest
{ {
string s = q"EOS string s = q"EOS
<?xml version="1.0" encoding="utf-8"?> <Tests> <?xml version="1.0" encoding="utf-8"?> <Tests>
@ -2879,7 +2885,7 @@ private
s = s[1..$]; s = s[1..$];
} }
char requireOneOf(ref string s, string chars) char requireOneOf(ref string s, string chars) @safe
{ {
if (s.length == 0 || indexOf(chars,s[0]) == -1) if (s.length == 0 || indexOf(chars,s[0]) == -1)
throw new TagException(""); throw new TagException("");
@ -3000,5 +3006,3 @@ private
throw new XMLException(s); throw new XMLException(s);
} }
} }