WIN_ASSERT_THROWS
WIN_ASSERT_THROWS can be used to check that a given expression raises a specific exception. If the expected exvception is not raised, the condition is treated as a failure. If an exception of a different type is raised, this exception will be treated as an unhandled exception, which, depending on your settings, will either lead to a debugger breakin or to the test case being aborted.
Note that WIN_ASSERT_THROWS can only be used to check for exceptions that can be caught by reference.
[in] Expression: The expression that is expected to raise an exception. If Expression returns a value, this value will be ignored.
[in] ExceptionType: The class name of the expected exception.
[in] ...: Optional: Message to be included in a failure report. This parameter allows printf-style formatters to be used, with the corresponding parameters being specified as subsequent arguments. The routine is overloaded and allows Message to be either a unicode or an ANSI string.
class TestException {};
static void RaiseTestException()
{
throw TestException();
}
BEGIN_TEST( TestForRaisedException )
{
WIN_ASSERT_THROWS( RaiseTestException(), TestException );
}
END_TEST
Table 7.52.
| User Mode | Kernel Mode | |
|---|---|---|
| Available since | 1.3 | N/A |
| Header | Declared in winunit.h | N/A |
| Library | Link to cfix.lib | N/A |
| DLL | cfix.dll | N/A |
| IRQL | N/A | N/A |
Requires cl version 14.00 (VisualStudio 2005) or better.



