googletest.cfg: Fix #9397 (syntaxError when macro is unknown) (#2255)

Also add test in googletest.cpp
This commit is contained in:
Sebastian 2019-10-09 19:53:58 +02:00 committed by GitHub
parent 9f4db5018d
commit 4d305d5c54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View File

@ -39,4 +39,16 @@
<define name="GTEST_CONCAT_TOKEN_(foo, bar)" value="GTEST_CONCAT_TOKEN_IMPL_(foo, bar)"/>
<define name="GTEST_CONCAT_TOKEN_IMPL_(foo, bar)" value="foo ## bar"/>
<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_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"/>
<define name="MATCHER_P4(name, p0, p1, p2, p3, description)" value="bool name##MatcherP4&lt;p0##_type, p1##_type, p2##_type, p3##_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_P5(name, p0, p1, p2, p3, p4, description)" value="bool name##MatcherP5&lt;p0##_type, p1##_type, p2##_type, p3##_type, p4##_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_P6(name, p0, p1, p2, p3, p4, p5, description)" value="bool name##MatcherP6&lt;p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_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_P7(name, p0, p1, p2, p3, p4, p5, p6, description)" value="bool name##MatcherP7&lt;p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, p6##_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_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)" value="bool name##MatcherP8&lt;p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, p6##_type, p7##_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_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)" value="bool name##MatcherP9&lt;p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, p6##_type, p7##_type, p8##_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_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)" value="bool name##MatcherP10&lt;p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type&gt;::gmock_Impl&lt;arg_type&gt;::MatchAndExplain(GTEST_REFERENCE_TO_CONST_(arg_type) arg,::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) const"/>
</def>

20
test/cfg/googletest.cpp Normal file
View File

@ -0,0 +1,20 @@
// Test library configuration for googletest.cfg
//
// Usage:
// $ cppcheck --check-library --library=googletest --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/googletest.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
#include <gmock/gmock-generated-matchers.h>
// #9397 syntaxError when MATCHER_P is not known
namespace ExampleNamespace {
constexpr long long TOLERANCE = 10;
MATCHER_P(ExampleMatcherTest, expected, "")
{
return ((arg <= (expected + TOLERANCE)) && (arg >= (expected - TOLERANCE)));
}
}

View File

@ -280,6 +280,8 @@ else
fi
${CPPCHECK} ${CPPCHECK_OPT} --library=cairo ${DIR}cairo.c
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=googletest ${DIR}googletest.cpp
# Check the syntax of the defines in the configuration files
set +e
xmlstarlet --version