How to catch an assert with Google test?
EXPECT_FATAL_FAILURE(statement,text) and EXPECT_NONFATAL_FAILURE(statement,text) will only pass if 'statement' invokes a failing ASSERT_x or EXECT_x respectively.
These statements will pass in your tests:
EXPECT_NONFATAL_FAILURE( EXPECT_TRUE( 0 ), "" );
EXPECT_FATAL_FAILURE( ASSERT_TRUE( 0 ), "" );
Google test provides ASSERT_DEATH
, EXPECT_DEATH
and other related macros.
This question and What are Google Test, Death Tests are each other's answers. Does that make them duplicates, or not? ;-)