Jon*_*age 4 testing nunit c++-cli exception expected-exception
你怎么做相当于:
[Test, ExpectedException( typeof(ArgumentOutOfRangeException) )]
void Test_Something_That_Throws_Exception()
{
throw gcnew ArgumentOutOfRangeException("Some more detail");
}
Run Code Online (Sandbox Code Playgroud)
...在C++中(有C#的例子)?据我所知,NUnit的C++实现没有typeof()函数.
为了避免其他人试图寻找它,这里是解决方案:
[Test, ExpectedException( ArgumentOutOfRangeException::typeid )]
void Test_Something_That_Throws_Exception()
{
throw gcnew ArgumentOutOfRangeException("Some more detail");
}
Run Code Online (Sandbox Code Playgroud)
只需使用::typeid例外:-)
| 归档时间: |
|
| 查看次数: |
1137 次 |
| 最近记录: |