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
6305ff5a
Commit
6305ff5a
authored
Apr 28, 2015
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change IsNull and NotNull to use ==/!= nullptr in C++11.
Also update gmock_doctor due to Clang wording change.
parent
5625dd33
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
gmock-matchers.h
include/gmock/gmock-matchers.h
+8
-0
gmock_doctor.py
scripts/gmock_doctor.py
+1
-1
gmock-matchers_test.cc
test/gmock-matchers_test.cc
+18
-0
No files found.
include/gmock/gmock-matchers.h
View file @
6305ff5a
...
@@ -979,7 +979,11 @@ class IsNullMatcher {
...
@@ -979,7 +979,11 @@ class IsNullMatcher {
template
<
typename
Pointer
>
template
<
typename
Pointer
>
bool
MatchAndExplain
(
const
Pointer
&
p
,
bool
MatchAndExplain
(
const
Pointer
&
p
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
#if GTEST_LANG_CXX11
return
p
==
nullptr
;
#else // GTEST_LANG_CXX11
return
GetRawPointer
(
p
)
==
NULL
;
return
GetRawPointer
(
p
)
==
NULL
;
#endif // GTEST_LANG_CXX11
}
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is NULL"
;
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is NULL"
;
}
...
@@ -995,7 +999,11 @@ class NotNullMatcher {
...
@@ -995,7 +999,11 @@ class NotNullMatcher {
template
<
typename
Pointer
>
template
<
typename
Pointer
>
bool
MatchAndExplain
(
const
Pointer
&
p
,
bool
MatchAndExplain
(
const
Pointer
&
p
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
#if GTEST_LANG_CXX11
return
p
!=
nullptr
;
#else // GTEST_LANG_CXX11
return
GetRawPointer
(
p
)
!=
NULL
;
return
GetRawPointer
(
p
)
!=
NULL
;
#endif // GTEST_LANG_CXX11
}
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"isn't NULL"
;
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"isn't NULL"
;
}
...
...
scripts/gmock_doctor.py
View file @
6305ff5a
...
@@ -362,7 +362,7 @@ def _MockObjectPointerDiagnoser(msg):
...
@@ -362,7 +362,7 @@ def _MockObjectPointerDiagnoser(msg):
r'which is of non-class type \'(.*::)*(?P<class_name>.+)\*\''
)
r'which is of non-class type \'(.*::)*(?P<class_name>.+)\*\''
)
clang_regex
=
(
_CLANG_FILE_LINE_RE
+
r'error: member reference type '
clang_regex
=
(
_CLANG_FILE_LINE_RE
+
r'error: member reference type '
r'\'(?P<class_name>.*?) *\' is a pointer; '
r'\'(?P<class_name>.*?) *\' is a pointer; '
r'
maybe you meant
to use \'->\'\?'
)
r'
(did you mean|maybe you meant)
to use \'->\'\?'
)
diagnosis
=
"""
diagnosis
=
"""
The first argument to ON_CALL() and EXPECT_CALL() must be a mock *object*,
The first argument to ON_CALL() and EXPECT_CALL() must be a mock *object*,
not a *pointer* to it. Please write '*(
%(mock_object)
s)' instead of
not a *pointer* to it. Please write '*(
%(mock_object)
s)' instead of
...
...
test/gmock-matchers_test.cc
View file @
6305ff5a
...
@@ -1025,6 +1025,15 @@ TEST(IsNullTest, ReferenceToConstLinkedPtr) {
...
@@ -1025,6 +1025,15 @@ TEST(IsNullTest, ReferenceToConstLinkedPtr) {
EXPECT_FALSE
(
m
.
Matches
(
non_null_p
));
EXPECT_FALSE
(
m
.
Matches
(
non_null_p
));
}
}
#if GTEST_LANG_CXX11
TEST
(
IsNullTest
,
StdFunction
)
{
const
Matcher
<
std
::
function
<
void
()
>>
m
=
IsNull
();
EXPECT_TRUE
(
m
.
Matches
(
std
::
function
<
void
()
>
()));
EXPECT_FALSE
(
m
.
Matches
([]{}));
}
#endif // GTEST_LANG_CXX11
TEST
(
IsNullTest
,
ReferenceToConstScopedPtr
)
{
TEST
(
IsNullTest
,
ReferenceToConstScopedPtr
)
{
const
Matcher
<
const
scoped_ptr
<
double
>&>
m
=
IsNull
();
const
Matcher
<
const
scoped_ptr
<
double
>&>
m
=
IsNull
();
const
scoped_ptr
<
double
>
null_p
;
const
scoped_ptr
<
double
>
null_p
;
...
@@ -1073,6 +1082,15 @@ TEST(NotNullTest, ReferenceToConstLinkedPtr) {
...
@@ -1073,6 +1082,15 @@ TEST(NotNullTest, ReferenceToConstLinkedPtr) {
EXPECT_TRUE
(
m
.
Matches
(
non_null_p
));
EXPECT_TRUE
(
m
.
Matches
(
non_null_p
));
}
}
#if GTEST_LANG_CXX11
TEST
(
NotNullTest
,
StdFunction
)
{
const
Matcher
<
std
::
function
<
void
()
>>
m
=
NotNull
();
EXPECT_TRUE
(
m
.
Matches
([]{}));
EXPECT_FALSE
(
m
.
Matches
(
std
::
function
<
void
()
>
()));
}
#endif // GTEST_LANG_CXX11
TEST
(
NotNullTest
,
ReferenceToConstScopedPtr
)
{
TEST
(
NotNullTest
,
ReferenceToConstScopedPtr
)
{
const
Matcher
<
const
scoped_ptr
<
double
>&>
m
=
NotNull
();
const
Matcher
<
const
scoped_ptr
<
double
>&>
m
=
NotNull
();
const
scoped_ptr
<
double
>
null_p
;
const
scoped_ptr
<
double
>
null_p
;
...
...
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