diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-10-17 09:26:58 +0800 | 
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-10-17 09:26:58 +0800 | 
| commit | a6b5b8b879a9a587ec0ad605722d5d6428d5e68c (patch) | |
| tree | 137fbe9d970e0aa8f501f0632054bf8fee1575ec /test/xml | |
| parent | aa05a34dd5e4a56563cbfeab273785ce0e363089 (diff) | |
| download | cru-a6b5b8b879a9a587ec0ad605722d5d6428d5e68c.tar.gz cru-a6b5b8b879a9a587ec0ad605722d5d6428d5e68c.tar.bz2 cru-a6b5b8b879a9a587ec0ad605722d5d6428d5e68c.zip | |
XML and mapper remove String.
Diffstat (limited to 'test/xml')
| -rw-r--r-- | test/xml/ParserTest.cpp | 70 | 
1 files changed, 35 insertions, 35 deletions
| diff --git a/test/xml/ParserTest.cpp b/test/xml/ParserTest.cpp index d998abb4..0d3ab1d7 100644 --- a/test/xml/ParserTest.cpp +++ b/test/xml/ParserTest.cpp @@ -6,79 +6,79 @@  using namespace cru::xml;  TEST_CASE("CruXmlParserTest Simple", "[xml]") { -  XmlParser parser(u"<root></root>"); +  XmlParser parser("<root></root>");    auto n = parser.Parse(); -  REQUIRE(n->GetTag() == u"root"); +  REQUIRE(n->GetTag() == "root");    REQUIRE(n->GetAttributes().empty() == true);    REQUIRE(n->GetChildCount() == 0);    delete n;  }  TEST_CASE("CruXmlParserTest SimpleWithAttribute", "[xml]") { -  XmlParser parser(u"<root a1=\"v1\" a2=\"v2\"></root>"); +  XmlParser parser("<root a1=\"v1\" a2=\"v2\"></root>");    auto n = parser.Parse(); -  REQUIRE(n->GetTag() == u"root"); -  REQUIRE(n->GetAttributeValue(u"a1") == u"v1"); -  REQUIRE(n->GetAttributeValue(u"a2") == u"v2"); +  REQUIRE(n->GetTag() == "root"); +  REQUIRE(n->GetAttributeValue("a1") == "v1"); +  REQUIRE(n->GetAttributeValue("a2") == "v2");    REQUIRE(n->GetChildCount() == 0);    delete n;  }  TEST_CASE("CruXmlParserTest SimpleSelfClosing", "[xml]") { -  XmlParser parser(u"<root a1=\"v1\" a2=\"v2\"/>"); +  XmlParser parser("<root a1=\"v1\" a2=\"v2\"/>");    auto n = parser.Parse(); -  REQUIRE(n->GetTag() == u"root"); -  REQUIRE(n->GetAttributeValue(u"a1") == u"v1"); -  REQUIRE(n->GetAttributeValue(u"a2") == u"v2"); +  REQUIRE(n->GetTag() == "root"); +  REQUIRE(n->GetAttributeValue("a1") == "v1"); +  REQUIRE(n->GetAttributeValue("a2") == "v2");    REQUIRE(n->GetChildCount() == 0);    delete n;  }  TEST_CASE("CruXmlParserTest NestedElement", "[xml]") {    XmlParser parser( -      u"<root><c1><d1></d1></c1><c2><d2></d2><d3></d3></c2></root>"); +      "<root><c1><d1></d1></c1><c2><d2></d2><d3></d3></c2></root>");    auto n = parser.Parse();    REQUIRE(n->GetChildren().size() == 2); -  REQUIRE(n->GetChildAt(0)->AsElement()->GetTag() == u"c1"); -  REQUIRE(n->GetChildAt(1)->AsElement()->GetTag() == u"c2"); +  REQUIRE(n->GetChildAt(0)->AsElement()->GetTag() == "c1"); +  REQUIRE(n->GetChildAt(1)->AsElement()->GetTag() == "c2");    REQUIRE(n->GetChildAt(0)->AsElement()->GetChildCount() == 1);    REQUIRE(n->GetChildAt(0)->AsElement()->GetChildAt(0)->AsElement()->GetTag() == -          u"d1"); +          "d1");    REQUIRE(n->GetChildAt(1)->AsElement()->GetChildCount() == 2);    REQUIRE(n->GetChildAt(1)->AsElement()->GetChildAt(0)->AsElement()->GetTag() == -          u"d2"); +          "d2");    REQUIRE(n->GetChildAt(1)->AsElement()->GetChildAt(1)->AsElement()->GetTag() == -          u"d3"); +          "d3");    delete n;  }  TEST_CASE("CruXmlParserTest SimpleText", "[xml]") { -  XmlParser parser(u"<root>text</root>"); +  XmlParser parser("<root>text</root>");    auto n = parser.Parse();    REQUIRE(n->GetChildCount() == 1); -  REQUIRE(n->GetChildAt(0)->AsText()->GetText() == u"text"); +  REQUIRE(n->GetChildAt(0)->AsText()->GetText() == "text");    delete n;  }  TEST_CASE("CruXmlParserTest Whitespace", "[xml]") { -  XmlParser parser(u"\t\t<root>\n\t\t\ttext test\n\t\t</root>\t\t"); +  XmlParser parser("\t\t<root>\n\t\t\ttext test\n\t\t</root>\t\t");    auto n = parser.Parse();    REQUIRE(n->GetChildCount() == 1); -  REQUIRE(n->GetChildAt(0)->AsText()->GetText() == u"text test"); +  REQUIRE(n->GetChildAt(0)->AsText()->GetText() == "text test");    delete n;  }  TEST_CASE("CruXmlParserTest Comment", "[xml]") { -  XmlParser parser(u"<!-- comment -->"); +  XmlParser parser("<!-- comment -->");    auto n = parser.Parse();    REQUIRE(n->IsCommentNode()); -  REQUIRE(n->AsComment()->GetText() == u"comment"); +  REQUIRE(n->AsComment()->GetText() == "comment");    delete n;  }  TEST_CASE("CruXmlParserTest Complex", "[xml]") {    XmlParser parser( -      uR"( +      R"(  <root a1="v1">    <c1>      <d1> @@ -95,22 +95,22 @@ TEST_CASE("CruXmlParserTest Complex", "[xml]") {  </root>    )");    auto n = parser.Parse(); -  REQUIRE(n->GetAttributeValue(u"a1") == u"v1"); +  REQUIRE(n->GetAttributeValue("a1") == "v1");    REQUIRE(n->GetChildCount() == 3); -  REQUIRE(n->GetChildAt(0)->AsElement()->GetTag() == u"c1"); +  REQUIRE(n->GetChildAt(0)->AsElement()->GetTag() == "c1");    REQUIRE(n->GetChildAt(0)->AsElement()->GetChildCount() == 1);    auto c2 = n->GetChildAt(1)->AsElement(); -  REQUIRE(c2->GetTag() == u"c2"); -  REQUIRE(c2->GetAttributeValue(u"a2") == u"v2"); -  REQUIRE(c2->GetAttributeValue(u"a3") == u"v3"); -  REQUIRE(c2->GetChildAt(0)->AsText()->GetText() == u"t1"); +  REQUIRE(c2->GetTag() == "c2"); +  REQUIRE(c2->GetAttributeValue("a2") == "v2"); +  REQUIRE(c2->GetAttributeValue("a3") == "v3"); +  REQUIRE(c2->GetChildAt(0)->AsText()->GetText() == "t1");    auto d2 = c2->GetChildAt(1)->AsElement(); -  REQUIRE(d2->GetTag() == u"d2"); -  REQUIRE(d2->GetAttributeValue(u"a4") == u"v4"); -  REQUIRE(c2->GetChildAt(2)->AsText()->GetText() == u"text test"); -  REQUIRE(c2->GetChildAt(3)->AsElement()->GetTag() == u"d3"); -  REQUIRE(c2->GetChildAt(4)->AsText()->GetText() == u"t2"); +  REQUIRE(d2->GetTag() == "d2"); +  REQUIRE(d2->GetAttributeValue("a4") == "v4"); +  REQUIRE(c2->GetChildAt(2)->AsText()->GetText() == "text test"); +  REQUIRE(c2->GetChildAt(3)->AsElement()->GetTag() == "d3"); +  REQUIRE(c2->GetChildAt(4)->AsText()->GetText() == "t2");    REQUIRE(n->GetChildAt(2)->IsCommentNode()); -  REQUIRE(n->GetChildAt(2)->AsComment()->GetText() == u"comment"); +  REQUIRE(n->GetChildAt(2)->AsComment()->GetText() == "comment");    delete n;  } | 
