This project is read-only.

List of WIN_ASSERT* Macros

These are the "asserts" you will use to verify conditions which, if not true, indicate a test failure.

Macro Description
WIN_ASSERT_EQUAL (expected, actual, ...) Compares expected and actual using ==; fails if they are not equal.
WIN_ASSERT_NOT_EQUAL (notExpected, actual, ...) Compares notExpected and actual using !=; fails if they are equal.
WIN_ASSERT_STRING_EQUAL (expected, actual, ...) Does a case-sensitive string comparison of expected and actual. Strings to be compared can be either wide-character or not, but both must be the same "wideness". (This does not affect the "wideness" of the optional message.)
WIN_ASSERT_ZERO (zeroExpression, ...) Compares zeroExpression to 0; fails if they are not equal.
WIN_ASSERT_NOT_ZERO (nonzeroExpression, ...) Compares nonzeroExpression to 0; fails if they are equal.
WIN_ASSERT_NULL (nullExpression, ...) Compares nullExpression to NULL; fails if they are not equal. Only works with pointers.
WIN_ASSERT_NOT_NULL (notNullExpression, ...) Compares notNullExpression to NULL; fails if they are equal. Only works with pointers.
WIN_ASSERT_FAIL (message, ...) Always fails; informational message is required.
WIN_ASSERT_TRUE (trueExpression, ...) Succeeds if trueExpression evaluates to true.
WIN_ASSERT_FALSE (falseExpression, ...) Succeeds if !falseExpression evaluates to true.
WIN_ASSERT_WINAPI_SUCCESS (trueExpression, ...) Succeeds if trueExpression evaluates to true. Use this with Windows functions whose documentation says to call GetLastError for more error information on failure. This macro/function calls GetLastError and includes the string associated with the error code as part of the message.
WIN_ASSERT_THROWS (expression, exceptionType, ...) Succeeds if expression throws a C++ exception of type exceptionType.

  • For either WIN_ ASSERT_EQUAL or WIN_ASSERT_NOT_EQUAL, if a numeric literal is passed in as one of the values and an unsigned number as the other, you'll get a signed/unsigned mismatch, as numeric literal integers always template-match to int. To get around this, postfix numeric literals with 'U' so they will match as unsigned.
  • All asserts take an optional printf-style format string, plus arguments. If _UNICODE is defined, these message strings will be wchar_t*, so use the _T ("") macro around the format strings, or L"" if you're building Unicode-only.

One additional macro which does not signify an error:

WIN_TRACE (message, ...) Used to output informational messages for debugging purposes. Its use does not cause a test failure. "message" is a printf-style format string, followed by any arguments.

See WinUnit.chm in the Documentation directory of the download for more information.

Last edited Sep 8, 2009 at 6:19 AM by mkblees, version 6


No comments yet.