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
8276dbae
Unverified
Commit
8276dbae
authored
May 22, 2018
by
Gennadiy Civil
Committed by
GitHub
May 22, 2018
Browse files
Merge pull request #1591 from sgraham/disabled-rtti
Fix gmock not building when -fno-rtti
parents
1814bed8
3b22e21c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+4
-4
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+2
-4
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
8276dbae
...
@@ -2371,6 +2371,7 @@ class PointeeMatcher {
...
@@ -2371,6 +2371,7 @@ class PointeeMatcher {
GTEST_DISALLOW_ASSIGN_
(
PointeeMatcher
);
GTEST_DISALLOW_ASSIGN_
(
PointeeMatcher
);
};
};
#if GTEST_HAS_RTTI
// Implements the WhenDynamicCastTo<T>(m) matcher that matches a pointer or
// Implements the WhenDynamicCastTo<T>(m) matcher that matches a pointer or
// reference that matches inner_matcher when dynamic_cast<T> is applied.
// reference that matches inner_matcher when dynamic_cast<T> is applied.
// The result of dynamic_cast<To> is forwarded to the inner matcher.
// The result of dynamic_cast<To> is forwarded to the inner matcher.
...
@@ -2397,11 +2398,7 @@ class WhenDynamicCastToMatcherBase {
...
@@ -2397,11 +2398,7 @@ class WhenDynamicCastToMatcherBase {
const
Matcher
<
To
>
matcher_
;
const
Matcher
<
To
>
matcher_
;
static
std
::
string
GetToName
()
{
static
std
::
string
GetToName
()
{
#if GTEST_HAS_RTTI
return
GetTypeName
<
To
>
();
return
GetTypeName
<
To
>
();
#else // GTEST_HAS_RTTI
return
"the target type"
;
#endif // GTEST_HAS_RTTI
}
}
private:
private:
...
@@ -2447,6 +2444,7 @@ class WhenDynamicCastToMatcher<To&> : public WhenDynamicCastToMatcherBase<To&> {
...
@@ -2447,6 +2444,7 @@ class WhenDynamicCastToMatcher<To&> : public WhenDynamicCastToMatcherBase<To&> {
return
MatchPrintAndExplain
(
*
to
,
this
->
matcher_
,
listener
);
return
MatchPrintAndExplain
(
*
to
,
this
->
matcher_
,
listener
);
}
}
};
};
#endif // GTEST_HAS_RTTI
// Implements the Field() matcher for matching a field (i.e. member
// Implements the Field() matcher for matching a field (i.e. member
// variable) of an object.
// variable) of an object.
...
@@ -4441,6 +4439,7 @@ inline internal::PointeeMatcher<InnerMatcher> Pointee(
...
@@ -4441,6 +4439,7 @@ inline internal::PointeeMatcher<InnerMatcher> Pointee(
return
internal
::
PointeeMatcher
<
InnerMatcher
>
(
inner_matcher
);
return
internal
::
PointeeMatcher
<
InnerMatcher
>
(
inner_matcher
);
}
}
#if GTEST_HAS_RTTI
// Creates a matcher that matches a pointer or reference that matches
// Creates a matcher that matches a pointer or reference that matches
// inner_matcher when dynamic_cast<To> is applied.
// inner_matcher when dynamic_cast<To> is applied.
// The result of dynamic_cast<To> is forwarded to the inner matcher.
// The result of dynamic_cast<To> is forwarded to the inner matcher.
...
@@ -4453,6 +4452,7 @@ WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
...
@@ -4453,6 +4452,7 @@ WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
return
MakePolymorphicMatcher
(
return
MakePolymorphicMatcher
(
internal
::
WhenDynamicCastToMatcher
<
To
>
(
inner_matcher
));
internal
::
WhenDynamicCastToMatcher
<
To
>
(
inner_matcher
));
}
}
#endif // GTEST_HAS_RTTI
// Creates a matcher that matches an object whose given field matches
// Creates a matcher that matches an object whose given field matches
// 'matcher'. For example,
// 'matcher'. For example,
...
...
googlemock/test/gmock-matchers_test.cc
View file @
8276dbae
...
@@ -3704,6 +3704,7 @@ MATCHER_P(FieldIIs, inner_matcher, "") {
...
@@ -3704,6 +3704,7 @@ MATCHER_P(FieldIIs, inner_matcher, "") {
return
ExplainMatchResult
(
inner_matcher
,
arg
.
i
,
result_listener
);
return
ExplainMatchResult
(
inner_matcher
,
arg
.
i
,
result_listener
);
}
}
#if GTEST_HAS_RTTI
TEST
(
WhenDynamicCastToTest
,
SameType
)
{
TEST
(
WhenDynamicCastToTest
,
SameType
)
{
Derived
derived
;
Derived
derived
;
derived
.
i
=
4
;
derived
.
i
=
4
;
...
@@ -3761,12 +3762,8 @@ TEST(WhenDynamicCastToTest, AmbiguousCast) {
...
@@ -3761,12 +3762,8 @@ TEST(WhenDynamicCastToTest, AmbiguousCast) {
TEST
(
WhenDynamicCastToTest
,
Describe
)
{
TEST
(
WhenDynamicCastToTest
,
Describe
)
{
Matcher
<
Base
*>
matcher
=
WhenDynamicCastTo
<
Derived
*>
(
Pointee
(
_
));
Matcher
<
Base
*>
matcher
=
WhenDynamicCastTo
<
Derived
*>
(
Pointee
(
_
));
#if GTEST_HAS_RTTI
const
std
::
string
prefix
=
const
std
::
string
prefix
=
"when dynamic_cast to "
+
internal
::
GetTypeName
<
Derived
*>
()
+
", "
;
"when dynamic_cast to "
+
internal
::
GetTypeName
<
Derived
*>
()
+
", "
;
#else // GTEST_HAS_RTTI
const
std
::
string
prefix
=
"when dynamic_cast, "
;
#endif // GTEST_HAS_RTTI
EXPECT_EQ
(
prefix
+
"points to a value that is anything"
,
Describe
(
matcher
));
EXPECT_EQ
(
prefix
+
"points to a value that is anything"
,
Describe
(
matcher
));
EXPECT_EQ
(
prefix
+
"does not point to a value that is anything"
,
EXPECT_EQ
(
prefix
+
"does not point to a value that is anything"
,
DescribeNegation
(
matcher
));
DescribeNegation
(
matcher
));
...
@@ -3799,6 +3796,7 @@ TEST(WhenDynamicCastToTest, BadReference) {
...
@@ -3799,6 +3796,7 @@ TEST(WhenDynamicCastToTest, BadReference) {
Base
&
as_base_ref
=
derived
;
Base
&
as_base_ref
=
derived
;
EXPECT_THAT
(
as_base_ref
,
Not
(
WhenDynamicCastTo
<
const
OtherDerived
&>
(
_
)));
EXPECT_THAT
(
as_base_ref
,
Not
(
WhenDynamicCastTo
<
const
OtherDerived
&>
(
_
)));
}
}
#endif // GTEST_HAS_RTTI
// Minimal const-propagating pointer.
// Minimal const-propagating pointer.
template
<
typename
T
>
template
<
typename
T
>
...
...
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