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
25958f3e
Commit
25958f3e
authored
Oct 22, 2010
by
vladlosev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes compiler warning when built with -std=c++0x.
parent
50f4deb1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
22 deletions
+33
-22
gtest-printers.h
include/gtest/gtest-printers.h
+1
-1
gtest.h
include/gtest/gtest.h
+22
-18
gtest.cc
src/gtest.cc
+2
-2
gtest_unittest.cc
test/gtest_unittest.cc
+8
-1
No files found.
include/gtest/gtest-printers.h
View file @
25958f3e
...
@@ -121,7 +121,7 @@ enum TypeKind {
...
@@ -121,7 +121,7 @@ enum TypeKind {
kProtobuf
,
// a protobuf type
kProtobuf
,
// a protobuf type
kConvertibleToInteger
,
// a type implicitly convertible to BiggestInt
kConvertibleToInteger
,
// a type implicitly convertible to BiggestInt
// (e.g. a named or unnamed enum type)
// (e.g. a named or unnamed enum type)
kOtherType
,
// anything else
kOtherType
// anything else
};
};
// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
...
...
include/gtest/gtest.h
View file @
25958f3e
...
@@ -281,20 +281,33 @@ class GTEST_API_ AssertionResult {
...
@@ -281,20 +281,33 @@ class GTEST_API_ AssertionResult {
// assertion's expectation). When nothing has been streamed into the
// assertion's expectation). When nothing has been streamed into the
// object, returns an empty string.
// object, returns an empty string.
const
char
*
message
()
const
{
const
char
*
message
()
const
{
return
message_
.
get
()
!=
NULL
&&
message_
->
c_str
()
!=
NULL
?
return
message_
.
get
()
!=
NULL
?
message_
->
c_str
()
:
""
;
message_
->
c_str
()
:
""
;
}
}
// TODO(vladl@google.com): Remove this after making sure no clients use it.
// TODO(vladl@google.com): Remove this after making sure no clients use it.
// Deprecated; please use message() instead.
// Deprecated; please use message() instead.
const
char
*
failure_message
()
const
{
return
message
();
}
const
char
*
failure_message
()
const
{
return
message
();
}
// Streams a custom failure message into this object.
// Streams a custom failure message into this object.
template
<
typename
T
>
AssertionResult
&
operator
<<
(
const
T
&
value
);
template
<
typename
T
>
AssertionResult
&
operator
<<
(
const
T
&
value
)
{
AppendMessage
(
Message
()
<<
value
);
return
*
this
;
}
// Allows streaming basic output manipulators such as endl or flush into
// this object.
AssertionResult
&
operator
<<
(
::
std
::
ostream
&
(
*
basic_manipulator
)(
::
std
::
ostream
&
stream
))
{
AppendMessage
(
Message
()
<<
basic_manipulator
);
return
*
this
;
}
private
:
private
:
// No implementation - we want AssertionResult to be
// Appends the contents of message to message_.
// copy-constructible but not assignable.
void
AppendMessage
(
const
Message
&
a_message
)
{
void
operator
=
(
const
AssertionResult
&
other
);
if
(
message_
.
get
()
==
NULL
)
message_
.
reset
(
new
::
std
::
string
);
message_
->
append
(
a_message
.
GetString
().
c_str
());
}
// Stores result of the assertion predicate.
// Stores result of the assertion predicate.
bool
success_
;
bool
success_
;
...
@@ -302,19 +315,10 @@ class GTEST_API_ AssertionResult {
...
@@ -302,19 +315,10 @@ class GTEST_API_ AssertionResult {
// construct is not satisfied with the predicate's outcome.
// construct is not satisfied with the predicate's outcome.
// Referenced via a pointer to avoid taking too much stack frame space
// Referenced via a pointer to avoid taking too much stack frame space
// with test assertions.
// with test assertions.
internal
::
scoped_ptr
<
internal
::
String
>
message_
;
internal
::
scoped_ptr
<
::
std
::
string
>
message_
;
};
// class AssertionResult
// Streams a custom failure message into this object.
GTEST_DISALLOW_ASSIGN_
(
AssertionResult
);
template
<
typename
T
>
};
AssertionResult
&
AssertionResult
::
operator
<<
(
const
T
&
value
)
{
Message
msg
;
if
(
message_
.
get
()
!=
NULL
)
msg
<<
*
message_
;
msg
<<
value
;
message_
.
reset
(
new
internal
::
String
(
msg
.
GetString
()));
return
*
this
;
}
// Makes a successful assertion result.
// Makes a successful assertion result.
GTEST_API_
AssertionResult
AssertionSuccess
();
GTEST_API_
AssertionResult
AssertionSuccess
();
...
...
src/gtest.cc
View file @
25958f3e
...
@@ -945,8 +945,8 @@ Message& Message::operator <<(const ::wstring& wstr) {
...
@@ -945,8 +945,8 @@ Message& Message::operator <<(const ::wstring& wstr) {
AssertionResult
::
AssertionResult
(
const
AssertionResult
&
other
)
AssertionResult
::
AssertionResult
(
const
AssertionResult
&
other
)
:
success_
(
other
.
success_
),
:
success_
(
other
.
success_
),
message_
(
other
.
message_
.
get
()
!=
NULL
?
message_
(
other
.
message_
.
get
()
!=
NULL
?
new
internal
::
S
tring
(
*
other
.
message_
)
:
new
::
std
::
s
tring
(
*
other
.
message_
)
:
static_cast
<
internal
::
S
tring
*>
(
NULL
))
{
static_cast
<
::
std
::
s
tring
*>
(
NULL
))
{
}
}
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
...
...
test/gtest_unittest.cc
View file @
25958f3e
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include <vector>
#include <vector>
#include <ostream>
// Verifies that the command line flag variables can be accessed
// Verifies that the command line flag variables can be accessed
// in code once <gtest/gtest.h> has been #included.
// in code once <gtest/gtest.h> has been #included.
...
@@ -4902,7 +4903,7 @@ TEST(AssertionResultTest, ConstructionWorks) {
...
@@ -4902,7 +4903,7 @@ TEST(AssertionResultTest, ConstructionWorks) {
EXPECT_STREQ
(
"ghi"
,
r5
.
message
());
EXPECT_STREQ
(
"ghi"
,
r5
.
message
());
}
}
// Tests that the negation fips the predicate result but keeps the message.
// Tests that the negation f
l
ips the predicate result but keeps the message.
TEST
(
AssertionResultTest
,
NegationWorks
)
{
TEST
(
AssertionResultTest
,
NegationWorks
)
{
AssertionResult
r1
=
AssertionSuccess
()
<<
"abc"
;
AssertionResult
r1
=
AssertionSuccess
()
<<
"abc"
;
EXPECT_FALSE
(
!
r1
);
EXPECT_FALSE
(
!
r1
);
...
@@ -4919,6 +4920,12 @@ TEST(AssertionResultTest, StreamingWorks) {
...
@@ -4919,6 +4920,12 @@ TEST(AssertionResultTest, StreamingWorks) {
EXPECT_STREQ
(
"abcd0true"
,
r
.
message
());
EXPECT_STREQ
(
"abcd0true"
,
r
.
message
());
}
}
TEST
(
AssertionResultTest
,
CanStreamOstreamManipulators
)
{
AssertionResult
r
=
AssertionSuccess
();
r
<<
"Data"
<<
std
::
endl
<<
std
::
flush
<<
std
::
ends
<<
"Will be visible"
;
EXPECT_STREQ
(
"Data
\n\\
0Will be visible"
,
r
.
message
());
}
// Tests streaming a user type whose definition and operator << are
// Tests streaming a user type whose definition and operator << are
// both in the global namespace.
// both in the global namespace.
class
Base
{
class
Base
{
...
...
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