Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
534570b5
Unverified
Commit
534570b5
authored
Jul 21, 2018
by
Masaru Tsuchiyama
Committed by
GitHub
Jul 21, 2018
Browse files
Merge branch 'master' into feature/fix-build-error-vs2017-win10-jp
parents
40cd5d11
2a151c93
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
32 deletions
+67
-32
googlemock/docs/CookBook.md
googlemock/docs/CookBook.md
+2
-2
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+22
-4
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+18
-18
googlemock/include/gmock/internal/gmock-internal-utils.h
googlemock/include/gmock/internal/gmock-internal-utils.h
+1
-1
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+24
-3
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+0
-4
No files found.
googlemock/docs/CookBook.md
View file @
534570b5
...
@@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic };
...
@@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic };
class
Buzz
{
class
Buzz
{
public:
public:
explicit
Buzz
(
AccessLevel
access
)
{
…
}
explicit
Buzz
(
AccessLevel
access
)
{
...
}
...
...
};
};
...
@@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code won’t compil
...
@@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code won’t compil
Quiz time! What do you think will happen if a
`Return(ByMove(...))`
action is
Quiz time! What do you think will happen if a
`Return(ByMove(...))`
action is
performed more than once (e.g. you write
performed more than once (e.g. you write
`
…
.WillRepeatedly(Return(ByMove(...)));`
)? Come think of it, after the first
`.WillRepeatedly(Return(ByMove(...)));`
)? Come think of it, after the first
time the action runs, the source value will be consumed (since it’s a move-only
time the action runs, the source value will be consumed (since it’s a move-only
value), so the next time around, there’s no value to move from -- you’ll get a
value), so the next time around, there’s no value to move from -- you’ll get a
run-time error that
`Return(ByMove(...))`
can only be run once.
run-time error that
`Return(ByMove(...))`
can only be run once.
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
534570b5
...
@@ -4529,6 +4529,20 @@ Property(PropertyType (Class::*property)() const &,
...
@@ -4529,6 +4529,20 @@ Property(PropertyType (Class::*property)() const &,
property
,
property
,
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
}
// Three-argument form for reference-qualified member functions.
template
<
typename
Class
,
typename
PropertyType
,
typename
PropertyMatcher
>
inline
PolymorphicMatcher
<
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
&>
>
Property
(
const
std
::
string
&
property_name
,
PropertyType
(
Class
::*
property
)()
const
&
,
const
PropertyMatcher
&
matcher
)
{
return
MakePolymorphicMatcher
(
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
&>
(
property_name
,
property
,
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
#endif
#endif
// Creates a matcher that matches an object iff the result of applying
// Creates a matcher that matches an object iff the result of applying
...
@@ -5165,13 +5179,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
...
@@ -5165,13 +5179,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
// Define variadic matcher versions. They are overloaded in
// Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template
<
typename
...
Args
>
template
<
typename
...
Args
>
internal
::
AllOfMatcher
<
Args
...
>
AllOf
(
const
Args
&
...
matchers
)
{
internal
::
AllOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
AllOf
(
return
internal
::
AllOfMatcher
<
Args
...
>
(
matchers
...);
const
Args
&
...
matchers
)
{
return
internal
::
AllOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
(
matchers
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
internal
::
AnyOfMatcher
<
Args
...
>
AnyOf
(
const
Args
&
...
matchers
)
{
internal
::
AnyOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
AnyOf
(
return
internal
::
AnyOfMatcher
<
Args
...
>
(
matchers
...);
const
Args
&
...
matchers
)
{
return
internal
::
AnyOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
(
matchers
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
...
...
googlemock/include/gmock/gmock-spec-builders.h
View file @
534570b5
...
@@ -1854,22 +1854,22 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
...
@@ -1854,22 +1854,22 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
// parameter. This technique may only be used for non-overloaded methods.
// parameter. This technique may only be used for non-overloaded methods.
//
//
// // These are the same:
// // These are the same:
// ON_CALL(mock, NoArgsMethod()).WillByDefault(
…
);
// ON_CALL(mock, NoArgsMethod()).WillByDefault(
...
);
// ON_CALL(mock, NoArgsMethod).WillByDefault(
…
);
// ON_CALL(mock, NoArgsMethod).WillByDefault(
...
);
//
//
// // As are these:
// // As are these:
// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(
…
);
// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(
...
);
// ON_CALL(mock, TwoArgsMethod).WillByDefault(
…
);
// ON_CALL(mock, TwoArgsMethod).WillByDefault(
...
);
//
//
// // Can also specify args if you want, of course:
// // Can also specify args if you want, of course:
// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(
…
);
// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(
...
);
//
//
// // Overloads work as long as you specify parameters:
// // Overloads work as long as you specify parameters:
// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(
…
);
// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(
...
);
// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(
…
);
// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(
...
);
//
//
// // Oops! Which overload did you want?
// // Oops! Which overload did you want?
// ON_CALL(mock, OverloadedMethod).WillByDefault(
…
);
// ON_CALL(mock, OverloadedMethod).WillByDefault(
...
);
// => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous
// => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous
//
//
// How this works: The mock class uses two overloads of the gmock_Method
// How this works: The mock class uses two overloads of the gmock_Method
...
@@ -1877,28 +1877,28 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
...
@@ -1877,28 +1877,28 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
// In the matcher list form, the macro expands to:
// In the matcher list form, the macro expands to:
//
//
// // This statement:
// // This statement:
// ON_CALL(mock, TwoArgsMethod(_, 45))
…
// ON_CALL(mock, TwoArgsMethod(_, 45))
...
//
//
// //
…
expands to:
// //
...
expands to:
// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)
…
// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)
...
// |-------------v---------------||------------v-------------|
// |-------------v---------------||------------v-------------|
// invokes first overload swallowed by operator()
// invokes first overload swallowed by operator()
//
//
// //
…
which is essentially:
// //
...
which is essentially:
// mock.gmock_TwoArgsMethod(_, 45)
…
// mock.gmock_TwoArgsMethod(_, 45)
...
//
//
// Whereas the form without a matcher list:
// Whereas the form without a matcher list:
//
//
// // This statement:
// // This statement:
// ON_CALL(mock, TwoArgsMethod)
…
// ON_CALL(mock, TwoArgsMethod)
...
//
//
// //
…
expands to:
// //
...
expands to:
// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)
…
// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)
...
// |-----------------------v--------------------------|
// |-----------------------v--------------------------|
// invokes second overload
// invokes second overload
//
//
// //
…
which is essentially:
// //
...
which is essentially:
// mock.gmock_TwoArgsMethod(_, _)
…
// mock.gmock_TwoArgsMethod(_, _)
...
//
//
// The WithoutMatchers() argument is used to disambiguate overloads and to
// The WithoutMatchers() argument is used to disambiguate overloads and to
// block the caller from accidentally invoking the second overload directly. The
// block the caller from accidentally invoking the second overload directly. The
...
...
googlemock/include/gmock/internal/gmock-internal-utils.h
View file @
534570b5
...
@@ -348,7 +348,7 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message,
...
@@ -348,7 +348,7 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message,
// correct overload. This must not be instantiable, to prevent client code from
// correct overload. This must not be instantiable, to prevent client code from
// accidentally resolving to the overload; for example:
// accidentally resolving to the overload; for example:
//
//
// ON_CALL(mock, Method({}, nullptr))
…
// ON_CALL(mock, Method({}, nullptr))
...
//
//
class
WithoutMatchers
{
class
WithoutMatchers
{
private:
private:
...
...
googlemock/test/gmock-matchers_test.cc
View file @
534570b5
...
@@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) {
...
@@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) {
}
}
// Helper to allow easy testing of AnyOf matchers with num parameters.
// Helper to allow easy testing of AnyOf matchers with num parameters.
void
AnyOfMatches
(
int
num
,
const
Matcher
<
int
>&
m
)
{
static
void
AnyOfMatches
(
int
num
,
const
Matcher
<
int
>&
m
)
{
SCOPED_TRACE
(
Describe
(
m
));
SCOPED_TRACE
(
Describe
(
m
));
EXPECT_FALSE
(
m
.
Matches
(
0
));
EXPECT_FALSE
(
m
.
Matches
(
0
));
for
(
int
i
=
1
;
i
<=
num
;
++
i
)
{
for
(
int
i
=
1
;
i
<=
num
;
++
i
)
{
...
@@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
...
@@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
EXPECT_FALSE
(
m
.
Matches
(
num
+
1
));
EXPECT_FALSE
(
m
.
Matches
(
num
+
1
));
}
}
#if GTEST_LANG_CXX11
static
void
AnyOfStringMatches
(
int
num
,
const
Matcher
<
std
::
string
>&
m
)
{
SCOPED_TRACE
(
Describe
(
m
));
EXPECT_FALSE
(
m
.
Matches
(
std
::
to_string
(
0
)));
for
(
int
i
=
1
;
i
<=
num
;
++
i
)
{
EXPECT_TRUE
(
m
.
Matches
(
std
::
to_string
(
i
)));
}
EXPECT_FALSE
(
m
.
Matches
(
std
::
to_string
(
num
+
1
)));
}
#endif
// Tests that AnyOf(m1, ..., mn) matches any value that matches at
// Tests that AnyOf(m1, ..., mn) matches any value that matches at
// least one of the given matchers.
// least one of the given matchers.
TEST
(
AnyOfTest
,
MatchesWhenAnyMatches
)
{
TEST
(
AnyOfTest
,
MatchesWhenAnyMatches
)
{
...
@@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
...
@@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
));
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
));
AnyOfStringMatches
(
50
,
AnyOf
(
"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"
));
}
}
// Tests the variadic version of the ElementsAreMatcher
// Tests the variadic version of the ElementsAreMatcher
...
@@ -4220,13 +4238,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) {
...
@@ -4220,13 +4238,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) {
// ref-qualified.
// ref-qualified.
TEST
(
PropertyTest
,
WorksForRefQualifiedProperty
)
{
TEST
(
PropertyTest
,
WorksForRefQualifiedProperty
)
{
Matcher
<
const
AClass
&>
m
=
Property
(
&
AClass
::
s_ref
,
StartsWith
(
"hi"
));
Matcher
<
const
AClass
&>
m
=
Property
(
&
AClass
::
s_ref
,
StartsWith
(
"hi"
));
Matcher
<
const
AClass
&>
m_with_name
=
Property
(
"s"
,
&
AClass
::
s_ref
,
StartsWith
(
"hi"
));
AClass
a
;
AClass
a
;
a
.
set_s
(
"hill"
);
a
.
set_s
(
"hill"
);
EXPECT_TRUE
(
m
.
Matches
(
a
));
EXPECT_TRUE
(
m
.
Matches
(
a
));
EXPECT_TRUE
(
m_with_name
.
Matches
(
a
));
a
.
set_s
(
"hole"
);
a
.
set_s
(
"hole"
);
EXPECT_FALSE
(
m
.
Matches
(
a
));
EXPECT_FALSE
(
m
.
Matches
(
a
));
EXPECT_FALSE
(
m_with_name
.
Matches
(
a
));
}
}
#endif
#endif
...
@@ -4570,7 +4592,7 @@ TEST(ResultOfTest, WorksForFunctors) {
...
@@ -4570,7 +4592,7 @@ TEST(ResultOfTest, WorksForFunctors) {
}
}
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
// functor with more th
e
n one operator() defined. ResultOf() must work
// functor with more th
a
n one operator() defined. ResultOf() must work
// for each defined operator().
// for each defined operator().
struct
PolymorphicFunctor
{
struct
PolymorphicFunctor
{
typedef
int
result_type
;
typedef
int
result_type
;
...
@@ -6764,4 +6786,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
...
@@ -6764,4 +6786,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
}
// namespace gmock_matchers_test
}
// namespace gmock_matchers_test
}
// namespace testing
}
// namespace testing
googletest/include/gtest/internal/gtest-port.h
View file @
534570b5
...
@@ -522,11 +522,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
...
@@ -522,11 +522,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif // !defined(GTEST_HAS_STD_STRING)
#endif // !defined(GTEST_HAS_STD_STRING)
#ifndef GTEST_HAS_GLOBAL_STRING
#ifndef GTEST_HAS_GLOBAL_STRING
// The user didn't tell us whether ::string is available, so we need
// to figure it out.
# define GTEST_HAS_GLOBAL_STRING 0
# define GTEST_HAS_GLOBAL_STRING 0
#endif // GTEST_HAS_GLOBAL_STRING
#endif // GTEST_HAS_GLOBAL_STRING
#ifndef GTEST_HAS_STD_WSTRING
#ifndef GTEST_HAS_STD_WSTRING
...
...
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