summaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorGennadiy Civil <misterg@google.com>2018-04-17 20:12:04 (GMT)
committerGennadiy Civil <misterg@google.com>2018-04-17 20:12:04 (GMT)
commitdff32aff97a682dfc603ac99bedc639b959e24a8 (patch)
tree4fad9320db485a823cd41f13f484b8edb7fce185 /googlemock
parent3f88bb1831e48029e52fefcf654bfab5cf3a952c (diff)
downloadgoogletest-dff32aff97a682dfc603ac99bedc639b959e24a8.zip
googletest-dff32aff97a682dfc603ac99bedc639b959e24a8.tar.gz
googletest-dff32aff97a682dfc603ac99bedc639b959e24a8.tar.bz2
http://cl/193060888
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/include/gmock/gmock-matchers.h18
-rw-r--r--googlemock/test/gmock-matchers_test.cc42
2 files changed, 55 insertions, 5 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 62e9233..7c70775 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -5202,19 +5202,27 @@ 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>
-inline internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) {
+internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) {
return internal::AllOfMatcher<Args...>(matchers...);
}
template <typename... Args>
-inline internal::AnyOfMatcher<Args...> AnyOf(const Args&... matchers) {
+internal::AnyOfMatcher<Args...> AnyOf(const Args&... matchers) {
return internal::AnyOfMatcher<Args...>(matchers...);
}
template <typename... Args>
-inline internal::UnorderedElementsAreMatcher<Args...>
-UnorderedElementsAreMatcher(const Args&... matchers) {
- return internal::UnorderedElementsAreMatcher<Args...>(matchers...);
+internal::ElementsAreMatcher<tuple<typename std::decay<Args>::type...>>
+ElementsAre(const Args&... matchers) {
+ return internal::ElementsAreMatcher<
+ tuple<typename std::decay<Args>::type...>>(make_tuple(matchers...));
+}
+
+template <typename... Args>
+internal::UnorderedElementsAreMatcher<tuple<typename std::decay<Args>::type...>>
+UnorderedElementsAre(const Args&... matchers) {
+ return internal::UnorderedElementsAreMatcher<
+ tuple<typename std::decay<Args>::type...>>(make_tuple(matchers...));
}
#endif // GTEST_LANG_CXX11
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index 16116b5..c2738c3 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -2742,6 +2742,48 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
41, 42, 43, 44, 45, 46, 47, 48, 49, 50));
}
+// Tests the variadic version of the ElementsAreMatcher
+TEST(ElementsAreTest, HugeMatcher) {
+ vector<int> test_vector;
+ test_vector.push_back(1);
+ test_vector.push_back(2);
+ test_vector.push_back(3);
+ test_vector.push_back(4);
+ test_vector.push_back(5);
+ test_vector.push_back(6);
+ test_vector.push_back(7);
+ test_vector.push_back(8);
+ test_vector.push_back(9);
+ test_vector.push_back(10);
+ test_vector.push_back(11);
+ test_vector.push_back(12);
+
+ EXPECT_THAT(test_vector,
+ ElementsAre(Eq(1), Eq(2), Lt(13), Eq(4), Eq(5), Eq(6), Eq(7),
+ Eq(8), Eq(9), Eq(10), Gt(1), Eq(12) ));
+}
+
+// Tests the variadic version of the UnorderedElementsAreMatcher
+TEST(ElementsAreTest, HugeMatcherUnordered) {
+ vector<int> test_vector;
+ test_vector.push_back(1);
+ test_vector.push_back(2);
+ test_vector.push_back(3);
+ test_vector.push_back(4);
+ test_vector.push_back(5);
+ test_vector.push_back(6);
+ test_vector.push_back(7);
+ test_vector.push_back(8);
+ test_vector.push_back(9);
+ test_vector.push_back(10);
+ test_vector.push_back(11);
+ test_vector.push_back(12);
+
+ EXPECT_THAT(test_vector,
+ UnorderedElementsAre(Eq(1), Eq(2), Eq(3), Eq(4), Eq(5), Eq(6), Eq(7),
+ Eq(8), Eq(9), Eq(10), Eq(11), Ne(122) ));
+}
+
#endif // GTEST_LANG_CXX11
// Tests that AnyOf(m1, ..., mn) describes itself properly.