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

CFIX_ASSERT_MESSAGE

CFIX_ASSERT_MESSAGE

Synopsis

Use CFIX_ASSERT_MESSAGE to assert any expression. If the expression evaluates to be false, the test case is considered to have failed. The report for a failed assertions includes the message, file and line number as well as the function name.

The macro allows printf-style formatting to construct the message. Consult the documentation of printf for a list of format specifiers.

In contrast to CFIX_ASSERT, not the expression itself but the message provided as a parameter will be displayed in the failure log.

Declaration
void CFIX_ASSERT_MESSAGE( 
	__in BOOL Expression, 
	__in PCTSTR Format, 
	... 
	);
				

If UNICODE has been defined, string parameters are expected to by of type PCWSTR. Otherwise, ANSI is assumed and string parameters are expected to by of type PCSTR.

Remarks

In kernel mode, ANSI strings are not supported. Strings are always assumed to by of type PCWSTR. Moreover, formatting can only take place at IRQL <= APC_LEVEL. At higher IRQL, formatting is skipped and the Format string is used as-is.

As variadic macro arguments have not been supported until cl 14.00, this macro is not available if downlevel compilers are used.

Usage example
CFIX_ASSERT_MESSAGE( a == 1, L"a should be one, but it is %d", a );
				
Requirements

Table 7.7. 

 User ModeKernel Mode
Available since1.21.2
HeaderDeclared in cfix.hDeclared in cfix.h
LibraryLink to cfix.libLink to cfixkdrv.lib
DLLcfix.dllN/A
IRQLN/ACallable at any IRQL