Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
03062e23
Commit
03062e23
authored
Mar 30, 2011
by
vladlosev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes 'formatting error or buffer exceeded' error when outputting long failure messages in XML.
parent
1d8c5af3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
gtest.cc
src/gtest.cc
+13
-17
No files found.
src/gtest.cc
View file @
03062e23
...
@@ -3032,7 +3032,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
...
@@ -3032,7 +3032,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
static
String
EscapeXml
(
const
char
*
str
,
bool
is_attribute
);
static
String
EscapeXml
(
const
char
*
str
,
bool
is_attribute
);
// Returns the given string with all characters invalid in XML removed.
// Returns the given string with all characters invalid in XML removed.
static
String
RemoveInvalidXmlCharacters
(
const
char
*
str
);
static
string
RemoveInvalidXmlCharacters
(
const
string
&
str
);
// Convenience wrapper around EscapeXml when str is an attribute value.
// Convenience wrapper around EscapeXml when str is an attribute value.
static
String
EscapeXmlAttribute
(
const
char
*
str
)
{
static
String
EscapeXmlAttribute
(
const
char
*
str
)
{
...
@@ -3166,17 +3166,14 @@ String XmlUnitTestResultPrinter::EscapeXml(const char* str, bool is_attribute) {
...
@@ -3166,17 +3166,14 @@ String XmlUnitTestResultPrinter::EscapeXml(const char* str, bool is_attribute) {
// Returns the given string with all characters invalid in XML removed.
// Returns the given string with all characters invalid in XML removed.
// Currently invalid characters are dropped from the string. An
// Currently invalid characters are dropped from the string. An
// alternative is to replace them with certain characters such as . or ?.
// alternative is to replace them with certain characters such as . or ?.
String
XmlUnitTestResultPrinter
::
RemoveInvalidXmlCharacters
(
const
char
*
str
)
{
string
XmlUnitTestResultPrinter
::
RemoveInvalidXmlCharacters
(
const
string
&
str
)
{
char
*
const
output
=
new
char
[
strlen
(
str
)
+
1
];
string
output
;
char
*
appender
=
output
;
output
.
reserve
(
str
.
size
());
for
(
char
ch
=
*
str
;
ch
!=
'\0'
;
ch
=
*++
str
)
for
(
string
::
const_iterator
it
=
str
.
begin
();
it
!=
str
.
end
();
++
it
)
if
(
IsValidXmlCharacter
(
ch
))
if
(
IsValidXmlCharacter
(
*
it
))
*
appender
++
=
ch
;
output
.
push_back
(
*
it
);
*
appender
=
'\0'
;
String
ret_value
(
output
);
return
output
;
delete
[]
output
;
return
ret_value
;
}
}
// The following routines generate an XML representation of a UnitTest
// The following routines generate an XML representation of a UnitTest
...
@@ -3256,12 +3253,11 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
...
@@ -3256,12 +3253,11 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
*
stream
<<
" <failure message=
\"
"
*
stream
<<
" <failure message=
\"
"
<<
EscapeXmlAttribute
(
part
.
summary
()).
c_str
()
<<
EscapeXmlAttribute
(
part
.
summary
()).
c_str
()
<<
"
\"
type=
\"\"
>"
;
<<
"
\"
type=
\"\"
>"
;
const
String
message
=
RemoveInvalidXmlCharacters
(
String
::
Format
(
const
string
location
=
internal
::
FormatCompilerIndependentFileLocation
(
"%s
\n
%s"
,
part
.
file_name
(),
part
.
line_number
());
internal
::
FormatCompilerIndependentFileLocation
(
const
string
message
=
location
+
"
\n
"
+
part
.
message
();
part
.
file_name
(),
part
.
line_number
()).
c_str
(),
OutputXmlCDataSection
(
stream
,
part
.
message
()).
c_str
());
RemoveInvalidXmlCharacters
(
message
).
c_str
());
OutputXmlCDataSection
(
stream
,
message
.
c_str
());
*
stream
<<
"</failure>
\n
"
;
*
stream
<<
"</failure>
\n
"
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment