-
Notifications
You must be signed in to change notification settings - Fork 89
/
TestData.h
163 lines (135 loc) · 7.91 KB
/
TestData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/**
@file
Define structure and test data for xml testing.
Copyright (C) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef TEST_DATA_H
#define TEST_DATA_H
typedef struct {
UINTN EscapedLength;
UINTN NotEscapedLength;
CHAR8 *StringEscaped; // Static xml escaped string
CHAR8 *StringNotEscaped; // Static string raw
CHAR8 *String; // dynamically allocated string during the test
} XmlStringParseContext;
XmlStringParseContext Context1 = { 50, 50, "Hello There Are No Escape Sequences In This String", "Hello There Are No Escape Sequences In This String", NULL };
XmlStringParseContext Context7Esc = { 95, 66, "Hello <There> Are "7" Escape Sequence's In This &lt; &1234 String", "Hello <There> Are \"7\" Escape Sequence's In This < &1234 String", NULL };
XmlStringParseContext ContextLT = { 72, 63, "Hello <There Are< 3 Less Than Escape < Sequences In This String", "Hello <There Are< 3 Less Than Escape < Sequences In This String", NULL };
XmlStringParseContext ContextGT = { 75, 66, "Hello >There Are> 3 Greater Than Escape > Sequences In This String", "Hello >There Are> 3 Greater Than Escape > Sequences In This String", NULL };
XmlStringParseContext ContextQuote = { 74, 59, "Hello "There Are" 3 Quote Escape " Sequences In This String", "Hello \"There Are\" 3 Quote Escape \" Sequences In This String", NULL };
XmlStringParseContext ContextApostrophe = { 79, 64, "Hello 'There Are' 3 Apostrophe Escape ' Sequences In This String", "Hello 'There Are' 3 Apostrophe Escape ' Sequences In This String", NULL };
XmlStringParseContext ContextAmp = { 75, 63, "Hello &There Are& 3 Ampersand Escape & Sequences In This String", "Hello &There Are& 3 Ampersand Escape & Sequences In This String", NULL };
XmlStringParseContext ContextAmpNoEsc = { 15, 15, "Hello & Goodbye", "Hello & Goodbye", NULL };
//
// Test XML parsing
//
typedef struct {
UINTN TotalElements;
UINTN TotalAttributes;
UINTN MaxDepth;
UINTN MaxAttributes;
CONST CHAR8 *InputXmlString;
CHAR8 *ToFreeXmlString;
XmlNode *Node;
} XmlTestContext;
CONST CHAR8 VerySimpleElementsOnly1[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
"abcd-1"
"</RootNode>";
CONST CHAR8 VerySimpleElementsOnly2[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode/>";
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\"?>"
"<RootNode>"
" <Gen1Node>Gen1Node1 contents</Gen1Node>"
" <Gen1Node>Gen1Node2 contents "
" <Gen2Node>Gen2Node1 contents</Gen2Node>"
" </Gen1Node>"
" <Gen1Node>Gen1Node3 contents "
" <Gen2Node>Gen2Node1 contents"
" <Gen3Node>Gen3Node1 contents</Gen3Node>"
" <Gen3Node>Gen2Node2 contents</Gen3Node>"
" </Gen2Node>"
" <Gen2Node>Gen2Node2 Long Contents Here Long Contents Here Long Contents Here</Gen2Node>"
" </Gen1Node>"
"</RootNode>";
CONST CHAR8 LongElement[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
" <Gen1Node>Gen1Node1 contents</Gen1Node>"
" <Gen1Node>Gen1Node2 contents "
" <Gen2Node>Gen2Node1 contents</Gen2Node>"
" <LongNodeData>"
" MIIDrjCCApqgAwIBAgIQc0nOztwB5qNLayWxmLzFhTAJBgUrDgMCHQUAMEwxCzAJBgNVBAYTAlVTMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xHTAbBgNVBAMeFABEAEYAQwBJAF8ASABUAFQAUABTMB4XDTE4MDUwMjE1NDczMVoXDTM5MTIzMTIzNTk1OVowTDELMAkGA1UEBhMCVVMxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEdMBsGA1UEAx4UAEQARgBDAEkAXwBIAFQAVABQAFMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC50eVITBEA5akSD1yode1hAA77q8FGQcpAhc3yCD5TwmPJdFd0H/51zWAYLqOgP2cu+GhZQn0sZNT1YRZS5HXnTxMBd1GYI6fPEYY9pu4PdD+Olc1z1D2qk+ItFyBXsXDWRMYUbeHeY++cUni2815OacC055pTJrLpVbqsoavPjswT6UxHmTFZ9PJVXiYdlcSVb4r8xLxfreDhl00vG6QPU/hE16cFLpCIzsZDZ+o4YqAfeTu0W9TMxMfFGeYKAG56DqY15Q5nSo04LOY3Z8OjnaeekohCN1gRV5QlIM6hGs09pRnNC5Qb54bpsAdnNJJBM7H0pB/FIr5dH2n1XM/ZAgMBAAGjgZMwgZAwDwYDVR0TAQH/BAUwAwIBADB9BgNVHQEEdjB0gBB08GR9c43yJ6xq+3luFHgpoU4wTDELMAkGA1UEBhMCVVMxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEdMBsGA1UEAx4UAEQARgBDAEkAXwBIAFQAVABQAFOCEHNJzs7cAeajS2slsZi8xYUwCQYFKw4DAh0FAAOCAQEABeIS7s+wYZaWfMOOuPcOSWyTGyKBjFgm6EI6F+/JoKlUth1uSyjJb2UM6n8ZkEnTnm5crm/txHdRbG/q7ccmRhN9+LDukWq9gm9F3ciFodXDwRhDq9rDWGyXkXV4mz/rrlckBWpM4iYCrYoJsg6FL7wQLbpiFdbGbmVWIaN3Q2jsOJ7xcJtt56xYZZ1sAn4PMcX8KkoUnpqH+/+c97bEUqC8414ljng1yC2+Ja+/SHJAKFj9TefN2v0k3dW7X1woP0xG9wZy9G8CtTJSPyKbD9S0Ps+/nxUPHHbyEdfdO0wct50eN/GNzYEyMjLeMc/klsW3V+0S0j895uKjU+CPgQ=="
" </LongNodeData>"
" </Gen1Node>"
" <Gen1Node>Gen1Node3 contents "
" <Gen2Node>Gen2Node1 contents"
" <Gen3Node>Gen3Node1 contents</Gen3Node>"
" <Gen3Node>Gen2Node2 contents</Gen3Node>"
" </Gen2Node>"
" <Gen2Node>Gen2Node2 Long Contents Here Long Contents Here Long Contents Here</Gen2Node>"
" </Gen1Node>"
"</RootNode>";
XmlTestContext SimpleElementsOnlyContext = { 9, 0, 4, 0, SimpleElementsOnly, NULL, NULL };
XmlTestContext LongElementContext = { 10, 0, 4, 0, LongElement, NULL, NULL };
CONST CHAR8 SimpleElementsAttributes[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
" <Gen1Node attribute1='value1' attribute2='value2'>Gen1Node1 contents</Gen1Node>"
"</RootNode>";
XmlTestContext SimpleElementsAttributesContext = { 2, 2, 2, 2, SimpleElementsAttributes, NULL, NULL };
CONST CHAR8 NonEncodedXmlAttribute1[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
" <Gen1Node attribute1='value1 < value2' attribute2='value2'>Gen1Node1 contents</Gen1Node>"
"</RootNode>";
XmlTestContext NonEncodedXmlAttribute1Context = { 2, 2, 2, 2, NonEncodedXmlAttribute1, NULL, NULL };
CONST CHAR8 NonEncodedXmlContent1[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
" <Gen1Node attribute1='value1 < value2' attribute2='value2'>Gen1Node1 contents < test</Gen1Node>"
"</RootNode>";
XmlTestContext NonEncodedXmlContent1Context = { 2, 2, 2, 2, NonEncodedXmlContent1, NULL, NULL };
CONST CHAR8 EncodedXmlAttribute1[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
" <Gen1Node attribute1='value1 < value2' attribute2='value2'>Gen1Node1 contents</Gen1Node>"
"</RootNode>";
XmlTestContext EncodedXmlAttribute1Context = { 2, 2, 2, 2, EncodedXmlAttribute1, NULL, NULL };
CONST CHAR8 EncodedXmlContent1[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<RootNode>"
" <Gen1Node attribute1='value1 < value2' attribute2='value2'>Gen1Node1 contents &alt; test</Gen1Node>"
"</RootNode>";
XmlTestContext EncodedXmlContent1Context = { 2, 2, 2, 2, EncodedXmlContent1, NULL, NULL };
#endif