diff options
author | crupest <crupest@outlook.com> | 2022-03-04 20:07:50 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-04 20:07:50 +0800 |
commit | 14e1b0f188d302b69816ddf12f5ac591fd76b91d (patch) | |
tree | 8481328cfa20a43b67abd5455c2e34fd42639e0b /test/xml/ParserTest.cpp | |
parent | 57353bd3acd97957cb5f970016fec52977cc6e95 (diff) | |
download | cru-14e1b0f188d302b69816ddf12f5ac591fd76b91d.tar.gz cru-14e1b0f188d302b69816ddf12f5ac591fd76b91d.tar.bz2 cru-14e1b0f188d302b69816ddf12f5ac591fd76b91d.zip |
...
Diffstat (limited to 'test/xml/ParserTest.cpp')
-rw-r--r-- | test/xml/ParserTest.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/xml/ParserTest.cpp b/test/xml/ParserTest.cpp index 04c25594..06536bfa 100644 --- a/test/xml/ParserTest.cpp +++ b/test/xml/ParserTest.cpp @@ -68,6 +68,14 @@ TEST(CruXmlParserTest, Whitespace) { delete n; } +TEST(CruXmlParserTest, Comment) { + XmlParser parser(u"<!-- comment -->"); + auto n = parser.Parse(); + ASSERT_TRUE(n->IsCommentNode()); + ASSERT_EQ(n->AsComment()->GetText(), u"comment"); + delete n; +} + TEST(CruXmlParserTest, Complex) { XmlParser parser( uR"( @@ -83,11 +91,12 @@ TEST(CruXmlParserTest, Complex) { <d3></d3> t2 </c2> + <!-- comment --> </root> )"); auto n = parser.Parse(); ASSERT_EQ(n->GetAttribute(u"a1"), u"v1"); - ASSERT_EQ(n->GetChildCount(), 2); + ASSERT_EQ(n->GetChildCount(), 3); ASSERT_EQ(n->GetChildAt(0)->AsElement()->GetTag(), u"c1"); ASSERT_EQ(n->GetChildAt(0)->AsElement()->GetChildCount(), 1); auto c2 = n->GetChildAt(1)->AsElement(); @@ -101,5 +110,7 @@ TEST(CruXmlParserTest, Complex) { ASSERT_EQ(c2->GetChildAt(2)->AsText()->GetText(), u"text test"); ASSERT_EQ(c2->GetChildAt(3)->AsElement()->GetTag(), u"d3"); ASSERT_EQ(c2->GetChildAt(4)->AsText()->GetText(), u"t2"); + ASSERT_TRUE(n->GetChildAt(2)->IsCommentNode()); + ASSERT_EQ(n->GetChildAt(2)->AsComment()->GetText(), u"comment"); delete n; } |