aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2011-03-16 17:10:39 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2011-03-16 17:10:39 +0000
commit86d2eeb1120a330cec8396aee97914dae909e237 (patch)
treebdc2612a9fa4a6cdcbdf3aec02fdea28ad9c7976 /test
parentfc8c6c479a5250b709ed7b4406e025439037e18e (diff)
downloadgoogletest-86d2eeb1120a330cec8396aee97914dae909e237.tar.gz
googletest-86d2eeb1120a330cec8396aee97914dae909e237.tar.bz2
googletest-86d2eeb1120a330cec8396aee97914dae909e237.zip
Prevents ADL in AllOf() and AnyOf() (by Manuel Klimek).
Diffstat (limited to 'test')
-rw-r--r--test/gmock-generated-matchers_test.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/gmock-generated-matchers_test.cc b/test/gmock-generated-matchers_test.cc
index 5e18471d..819f1a83 100644
--- a/test/gmock-generated-matchers_test.cc
+++ b/test/gmock-generated-matchers_test.cc
@@ -1091,6 +1091,35 @@ TEST(ContainsTest, WorksForTwoDimensionalNativeArray) {
EXPECT_THAT(a, Contains(Not(Contains(5))));
}
+namespace adl_test {
+
+// Verifies that the implementation of ::testing::AllOf and ::testing::AnyOf
+// don't issue unqualified recursive calls. If they do, the argument dependent
+// name lookup will cause AllOf/AnyOf in the 'adl_test' namespace to be found
+// as a candidate and the compilation will break due to an ambiguous overload.
+
+// The matcher must be in the same namespace as AllOf/AnyOf to make argument
+// dependent lookup find those.
+MATCHER(M, "") { return true; }
+
+template <typename T1, typename T2>
+bool AllOf(const T1& t1, const T2& t2) { return true; }
+
+TEST(AllOfTest, DoesNotCallAllOfUnqualified) {
+ EXPECT_THAT(42, testing::AllOf(
+ M(), M(), M(), M(), M(), M(), M(), M(), M(), M()));
+}
+
+template <typename T1, typename T2> bool
+AnyOf(const T1& t1, const T2& t2) { return true; }
+
+TEST(AnyOfTest, DoesNotCallAnyOfUnqualified) {
+ EXPECT_THAT(42, testing::AnyOf(
+ M(), M(), M(), M(), M(), M(), M(), M(), M(), M()));
+}
+
+} // namespace adl_test
+
#ifdef _MSC_VER
# pragma warning(pop)
#endif