Visual Assert – The Unit Testing Add-In for Visual C++
cfix – C/C++ Unit Testing for Win32 and NT
 
 

CFIXCC_METHOD_EXPECT_EXCEPTION

CFIXCC_METHOD_EXPECT_EXCEPTION

Synopsis

Used to add a test method to the fixture that is expected to throw an exception of a particular type. If the method does not throw this exception, the test is treated as having failed. If the method throws an exception of a different, non-compatible type, CFIXCC_METHOD_EXPECT_EXCEPTION will not handle this exception. Rather, the exception is treated as unexpected and the default handling of unexpected exception applies.

CFIXCC_METHOD_EXPECT_EXCEPTION may be used any number of times per fixture.

Declaration
CFIXCC_METHOD_EXPECT_EXCEPTION( Method, ExceptionClass )
				

Test methods must have the following signature:

void TestMethod();
				
Remarks

Exceptions are caught by reference. Heap allocated exceptions are not supported by CFIXCC_METHOD_EXPECT_EXCEPTION.

Usage example
#include <cfixcc.h>

class FooException {};

class SimpleFixture : public cfixcc::TestFixture
{
public:
  void Method01() 
  {
	...
  }
  void MethodThatThrows() 
  {
	throw FooException();
  }
};

CFIXCC_BEGIN_CLASS( SimpleFixture )
  CFIXCC_METHOD( Method01 )
  CFIXCC_METHOD_EXPECT_EXCEPTION( MethodThatThrows, FooException )
CFIXCC_END_CLASS()
				
Requirements

Table 7.40. 

 User ModeKernel Mode
Available since1.2N/A
HeaderDeclared in cfixcc.hN/A
LibraryLink to cfix.libN/A
DLLcfix.dllN/A
IRQLN/AN/A