summaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorGennadiy Civil <gennadiycivil@users.noreply.github.com>2018-07-19 17:31:15 (GMT)
committerGitHub <noreply@github.com>2018-07-19 17:31:15 (GMT)
commit6ce9b98f541b8bcd84c5c5b3483f29a933c4aefb (patch)
tree4e62778f0cf8752eaea7a4ee3ebe8316fe29f91b /googlemock
parent1370e7658b659247f3c37cd1f07d917d0bd546a0 (diff)
parent61b819721758870d68cc07c07f27cf19004a5e88 (diff)
downloadgoogletest-6ce9b98f541b8bcd84c5c5b3483f29a933c4aefb.zip
googletest-6ce9b98f541b8bcd84c5c5b3483f29a933c4aefb.tar.gz
googletest-6ce9b98f541b8bcd84c5c5b3483f29a933c4aefb.tar.bz2
Merge pull request #1674 from gennadiycivil/master
Code Sync
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/include/gmock/gmock-matchers.h12
-rw-r--r--googlemock/test/gmock-matchers_test.cc24
2 files changed, 29 insertions, 7 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index c94f582..7fd5787 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -5165,13 +5165,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
// Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template <typename... Args>
-internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) {
- return internal::AllOfMatcher<Args...>(matchers...);
+internal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(
+ const Args&... matchers) {
+ return internal::AllOfMatcher<typename std::decay<const Args&>::type...>(
+ matchers...);
}
template <typename... Args>
-internal::AnyOfMatcher<Args...> AnyOf(const Args&... matchers) {
- return internal::AnyOfMatcher<Args...>(matchers...);
+internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
+ const Args&... matchers) {
+ return internal::AnyOfMatcher<typename std::decay<const Args&>::type...>(
+ matchers...);
}
template <typename... Args>
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index 87b2ad5..f9dfd3c 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) {
}
// 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));
EXPECT_FALSE(m.Matches(0));
for (int i = 1; i <= num; ++i) {
@@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
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
// least one of the given matchers.
TEST(AnyOfTest, MatchesWhenAnyMatches) {
@@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
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));
+ 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
@@ -2777,6 +2795,7 @@ TEST(ElementsAreTest, HugeMatcherUnordered) {
#endif // GTEST_LANG_CXX11
+
// Tests that AnyOf(m1, ..., mn) describes itself properly.
TEST(AnyOfTest, CanDescribeSelf) {
Matcher<int> m;
@@ -4570,7 +4589,7 @@ TEST(ResultOfTest, WorksForFunctors) {
}
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
-// functor with more then one operator() defined. ResultOf() must work
+// functor with more than one operator() defined. ResultOf() must work
// for each defined operator().
struct PolymorphicFunctor {
typedef int result_type;
@@ -6764,4 +6783,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
} // namespace gmock_matchers_test
} // namespace testing
-