Fix #9964 (false positive: compareBoolExpressionWithInt with ASSERT_FALSE() and --library=googletest) (#2876)

This commit is contained in:
Oliver Stöneberg 2020-11-03 10:20:25 +01:00 committed by GitHub
parent e053066d8b
commit 98946143f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<!-- see https://github.com/google/googletest/blob/master/googletest/docs/primer.md -->
<define name="ASSERT_TRUE(cond)" value="assert(cond)"/>
<define name="EXPECT_TRUE(cond)" value="(void)(cond)"/>
<define name="ASSERT_FALSE(cond)" value="assert(!cond)"/>
<define name="ASSERT_FALSE(cond)" value="assert(!(cond))"/>
<define name="EXPECT_FALSE(cond)" value="(void)(cond)"/>
<define name="ASSERT_EQ(val1,val2)" value="assert((val1)==(val2))"/>
<define name="EXPECT_EQ(val1,val2)" value="(void)((val1)==(val2))"/>

View File

@ -44,3 +44,9 @@ TEST(test_cppcheck, cppcheck)
ASSERT_THROW(it.operator->(), std::out_of_range);
}
// #9964 - avoid compareBoolExpressionWithInt false positive
TEST(Test, assert_false_fp)
{
// cppcheck-suppress checkLibraryNoReturn
ASSERT_FALSE(errno < 0);
}