Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pugixml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SCALE
Code
external
pugixml
Commits
fc6c8633
Commit
fc6c8633
authored
9 years ago
by
Arseny Kapoulkine
Browse files
Options
Downloads
Patches
Plain Diff
tests: Add test for parse_embed_pcdata
parent
bcddf365
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_parse.cpp
+43
-0
43 additions, 0 deletions
tests/test_parse.cpp
with
43 additions
and
0 deletions
tests/test_parse.cpp
+
43
−
0
View file @
fc6c8633
...
@@ -1139,3 +1139,46 @@ TEST(parse_fuzz_doctype)
...
@@ -1139,3 +1139,46 @@ TEST(parse_fuzz_doctype)
xml_document
doc
;
xml_document
doc
;
CHECK
(
doc
.
load_buffer
(
data
,
sizeof
(
data
)).
status
==
status_bad_doctype
);
CHECK
(
doc
.
load_buffer
(
data
,
sizeof
(
data
)).
status
==
status_bad_doctype
);
}
}
TEST
(
parse_embed_pcdata
)
{
// parse twice - once with default and once with embed_pcdata flags
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
unsigned
int
flags
=
(
i
==
0
)
?
parse_default
:
parse_default
|
parse_embed_pcdata
;
xml_document
doc
;
xml_parse_result
res
=
doc
.
load_string
(
STR
(
"<node><key>value</key><child><inner1>value1</inner1><inner2>value2</inner2>outer</child><two>text<data /></two></node>"
),
flags
);
CHECK
(
res
);
xml_node
child
=
doc
.
child
(
STR
(
"node"
)).
child
(
STR
(
"child"
));
// parse_embed_pcdata omits PCDATA nodes so DOM is different
if
(
flags
&
parse_embed_pcdata
)
{
CHECK_STRING
(
doc
.
child
(
STR
(
"node"
)).
child
(
STR
(
"key"
)).
value
(),
STR
(
"value"
));
CHECK
(
!
doc
.
child
(
STR
(
"node"
)).
child
(
STR
(
"key"
)).
first_child
());
}
else
{
CHECK_STRING
(
doc
.
child
(
STR
(
"node"
)).
child
(
STR
(
"key"
)).
value
(),
STR
(
""
));
CHECK
(
doc
.
child
(
STR
(
"node"
)).
child
(
STR
(
"key"
)).
first_child
());
CHECK_STRING
(
doc
.
child
(
STR
(
"node"
)).
child
(
STR
(
"key"
)).
first_child
().
value
(),
STR
(
"value"
));
}
// higher-level APIs work the same though
CHECK_STRING
(
child
.
text
().
get
(),
STR
(
"outer"
));
CHECK_STRING
(
child
.
child
(
STR
(
"inner1"
)).
text
().
get
(),
STR
(
"value1"
));
CHECK_STRING
(
child
.
child_value
(),
STR
(
"outer"
));
CHECK_STRING
(
child
.
child_value
(
STR
(
"inner2"
)),
STR
(
"value2"
));
#ifndef PUGIXML_NO_XPATH
CHECK_XPATH_NUMBER
(
doc
,
STR
(
"count(node/child/*[starts-with(., 'value')])"
),
2
);
#endif
CHECK_NODE
(
doc
,
STR
(
"<node><key>value</key><child><inner1>value1</inner1><inner2>value2</inner2>outer</child><two>text<data /></two></node>"
));
CHECK_NODE_EX
(
doc
,
STR
(
"<node>
\n
<key>value</key>
\n
<child>
\n
<inner1>value1</inner1>
\n
<inner2>value2</inner2>outer</child>
\n
<two>text<data />
\n
</two>
\n
</node>
\n
"
),
STR
(
"
\t
"
),
0
);
CHECK_NODE_EX
(
doc
,
STR
(
"<node>
\n\t
<key>value</key>
\n\t
<child>
\n\t\t
<inner1>value1</inner1>
\n\t\t
<inner2>value2</inner2>outer</child>
\n\t
<two>text<data />
\n\t
</two>
\n
</node>
\n
"
),
STR
(
"
\t
"
),
format_indent
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment