Fix googletest.cfg macros ASSERT_THROW and EXPECT_THROW to avoid syntax errors

This commit is contained in:
Daniel Marjamäki 2020-09-30 18:45:04 +02:00
parent 63917bc3c3
commit 1548bf2267
2 changed files with 10 additions and 2 deletions

View File

@ -25,8 +25,8 @@
<define name="EXPECT_STRCASEEQ(str1,str2)" value="(void)(*(str1)==*(str2))"/>
<define name="ASSERT_STRCASENE(str1,str2)" value="assert(stricmp(str1, str2) != 0)"/>
<define name="EXPECT_STRCASENE(str1,str2)" value="(void)(*(str1)!=*(str2))"/>
<define name="ASSERT_THROW(code, e)" value="try{code}catch(e){}"/>
<define name="EXPECT_THROW(code, e)" value="try{code}catch(e){}"/>
<define name="ASSERT_THROW(code, e)" value="try{code;}catch(e){}"/>
<define name="EXPECT_THROW(code, e)" value="try{code;}catch(e){}"/>
<define name="TEST(A,B)" value="void __ ## A ## _ ## B ( )"/>
<define name="TEST_F(A,B)" value="void __ ## A ## _ ## B ( )"/>
<define name="TEST_P(A,B)" value="void __ ## A ## _ ## B ( )"/>

View File

@ -36,3 +36,11 @@ TEST(ASSERT, ASSERT)
free(a);
}
// Avoid syntax error: https://sourceforge.net/p/cppcheck/discussion/general/thread/6ccc7283e2/
TEST(test_cppcheck, cppcheck)
{
TestStruct<int> it;
ASSERT_THROW(it.operator->(), std::out_of_range);
}