Skip to content

Commit

Permalink
add testcase for two root nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Yang committed Apr 9, 2024
1 parent 01c4778 commit 30348f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions XmlSupportPkg/Test/UnitTest/XmlTreeLib/TestData.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ typedef struct {
CONST CHAR8 VerySimpleElementsOnly1[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
"abcd-1"
"</RootNode>";

CONST CHAR8 VerySimpleElementsOnly2[] =
Expand All @@ -54,16 +55,33 @@ CONST CHAR8 VerySimpleElementsOnly2[] =
CONST CHAR8 VerySimpleElementsOnly3[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
"abcd-3"
"</RootNode>\r\n\xcd\xcd";

CONST CHAR8 VerySimpleElementsOnly4[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode/>\r\n\xcd\xcd";

CONST CHAR8 VerySimpleElementsOnly5[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
"abcd-5"
"</RootNode>"
"<RootNode2>"
"xyz-5"
"</RootNode2>";

CONST CHAR8 VerySimpleElementsOnly6[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode/>"
"<RootNode2/>";

XmlTestContext VerySimpleElementsOnly1Context = { 1, 0, 1, 0, VerySimpleElementsOnly1, NULL, NULL };
XmlTestContext VerySimpleElementsOnly2Context = { 1, 0, 1, 0, VerySimpleElementsOnly2, NULL, NULL };
XmlTestContext VerySimpleElementsOnly3Context = { 1, 0, 1, 0, VerySimpleElementsOnly3, NULL, NULL };
XmlTestContext VerySimpleElementsOnly4Context = { 1, 0, 1, 0, VerySimpleElementsOnly4, NULL, NULL };
XmlTestContext VerySimpleElementsOnly5Context = { 1, 0, 1, 0, VerySimpleElementsOnly5, NULL, NULL };
XmlTestContext VerySimpleElementsOnly6Context = { 1, 0, 1, 0, VerySimpleElementsOnly6, NULL, NULL };

CONST CHAR8 SimpleElementsOnly[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
Expand Down
3 changes: 3 additions & 0 deletions XmlSupportPkg/Test/UnitTest/XmlTreeLib/XmlTreeLibUnitTests.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ UnitTestingEntry (
AddTestCase (InputTestSuite, "Parse Valid XML with a very simple empty tag root", "ValidElements", ParseValidXml, NULL, CleanUpXmlTestContext, &VerySimpleElementsOnly2Context);
AddTestCase (InputTestSuite, "Parse Valid XML with a very simple root, tailing with uninitialized memory", "ValidElements", ParseValidXml, NULL, CleanUpXmlTestContext, &VerySimpleElementsOnly3Context);
AddTestCase (InputTestSuite, "Parse Valid XML with a very simple empty tag root, tailing with uninitialized memory", "ValidElements", ParseValidXml, NULL, CleanUpXmlTestContext, &VerySimpleElementsOnly4Context);
AddTestCase (InputTestSuite, "Parse Valid XML with two very simple roots, report only first root", "ValidElements", ParseValidXml, NULL, CleanUpXmlTestContext, &VerySimpleElementsOnly5Context);
AddTestCase (InputTestSuite, "Parse Valid XML with two very simple empty tag roots, report only first root", "ValidElements", ParseValidXml, NULL, CleanUpXmlTestContext, &VerySimpleElementsOnly6Context);

AddTestCase (InputTestSuite, "Parse Valid XML with simple elements 3 layers", "ValidElements", ParseValidXml, NULL, CleanUpXmlTestContext, &SimpleElementsOnlyContext);
AddTestCase (InputTestSuite, "Parse Valid XML with 2 elements and 2 attributes", "ValidElementsAndAttributes", ParseValidXml, NULL, CleanUpXmlTestContext, &SimpleElementsAttributesContext);
AddTestCase (InputTestSuite, "Parse Invalid XML string containing an attribute with invalid xml chars", "NonXmlEncodedAttribute", ParseValidXml, NULL, CleanUpXmlTestContext, &NonEncodedXmlAttribute1Context);
Expand Down

0 comments on commit 30348f3

Please sign in to comment.