googletest.cfg; add MATCHER (#2485)

This commit is contained in:
Steven Hoving 2020-01-12 08:11:58 +01:00 committed by Daniel Marjamäki
parent c6e74f4c10
commit 26e403893c
2 changed files with 10 additions and 3 deletions

View File

@ -43,6 +43,7 @@
<define name="GTEST_STRINGIFY_(name)" value="#name"/>
<define name="GTEST_REFERENCE_TO_CONST_(T)" value="typename ::testing::internal::ConstRef&lt;T&gt;::type"/>
<define name="GTEST_ATTRIBUTE_UNUSED_" value="__attribute__ ((unused))"/>
<define name="MATCHER(name, description,...)" value="bool name##Matcher&lt;_type&gt;::gmock_Impl&lt;arg_type&gt;::MatchAndExplain( GTEST_REFERENCE_TO_CONST_(arg_type) arg, ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) const"/>
<define name="MATCHER_P(name, p0, description)" value="bool name##MatcherP&lt;p0##_type&gt;::gmock_Impl&lt;arg_type&gt;::MatchAndExplain( GTEST_REFERENCE_TO_CONST_(arg_type) arg, ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) const"/>
<define name="MATCHER_P2(name, p0, p1, description)" value="bool name##MatcherP2&lt;p0##_type, p1##_type&gt;::gmock_Impl&lt;arg_type&gt;::MatchAndExplain(GTEST_REFERENCE_TO_CONST_(arg_type) arg,::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) const"/>
<define name="MATCHER_P3(name, p0, p1, p2, description)" value="bool name##MatcherP3&lt;p0##_type, p1##_type, p2##_type&gt;::gmock_Impl&lt;arg_type&gt;::MatchAndExplain(GTEST_REFERENCE_TO_CONST_(arg_type) arg,::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) const"/>

View File

@ -10,16 +10,22 @@
#include <gmock/gmock-generated-matchers.h>
#include <gtest/gtest.h>
// #9397 syntaxError when MATCHER_P is not known
namespace ExampleNamespace {
constexpr long long TOLERANCE = 10;
MATCHER_P(ExampleMatcherTest, expected, "")
// #9397 syntaxError when MATCHER_P is not known
MATCHER_P(ExampleMatcherPTest, expected, "")
{
return ((arg <= (expected + TOLERANCE)) && (arg >= (expected - TOLERANCE)));
}
}
// syntaxError when MATCHER is not known
MATCHER(ExampleMatcherTest, "")
{
return (arg == TOLERANCE);
}
}
TEST(ASSERT, ASSERT)
{