获取 google 测试异常抛出消息
Get google test exception throw message
我正在为我的项目使用 google 测试框架。我从代码中抛出异常:
throw DerivedClassException("message");
并在测试框架中使用:
ASSERT_THROW(commond(), DerivedClassException);
我想通过 what()
API 接收消息。
任何获取异常的确切异常消息的方法。
检查抛出的异常的唯一方法是在测试中捕获它:
void test_foo( MyTest, TestException )
{
try
{
functionThatThrowsException();
FAIL();
}
catch( const DerivedClassException& err )
{
// check exception
ASSERT_STREQ( "error message", err.what() );
}
}
我正在为我的项目使用 google 测试框架。我从代码中抛出异常:
throw DerivedClassException("message");
并在测试框架中使用:
ASSERT_THROW(commond(), DerivedClassException);
我想通过 what()
API 接收消息。
任何获取异常的确切异常消息的方法。
检查抛出的异常的唯一方法是在测试中捕获它:
void test_foo( MyTest, TestException )
{
try
{
functionThatThrowsException();
FAIL();
}
catch( const DerivedClassException& err )
{
// check exception
ASSERT_STREQ( "error message", err.what() );
}
}