WIN_ASSERT_EQUAL allows typesafe comparison of values. Failed comparisons are treated as a failure, i.e. in the same manner as a failed WIN_ASSERT_TRUE. The benefit over using WIN_ASSERT_TRUE( Expected == Actual ) is that the expected and actual value will be visible in the failure report.
void WIN_ASSERT_EQUAL( __in T Expected, __in U Actual, ... );
T and U may either be the same type or compatible types. That is, an appropriate operator== must have been implemented that allows objects of type T and U to be checked for equality.
[in] Expected: The expected value.
[in] Actual: The actual value that is to be checked.
[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.
Please refer to the remarks section of CFIXCC_ASSERT_EQUALS for a discussion on how comparisons are conducted.
|To compare strings, please use WIN_ASSERT_STRING_EQUAL.|
When comparing non-primitive objects, consider providing an appropriate WinUnit::ToString implementation.
WIN_ASSERT_EQUAL( 42, Answer, "Answer should be 42" ); WIN_ASSERT_EQUAL( 42, Answer, L"Answer should be %d", 42 ); WIN_ASSERT_EQUAL( 2.0, 2, "Double/int - exact equality check" ); // // Float/double comparisons with relaxed precision. // (All of the following assertions succeed). // WIN_ASSERT_EQUAL( 1.9999999f, 2.0f, "Two floats - relaxed check" ); WIN_ASSERT_EQUAL( 2.0f, 1.9999999f ); WIN_ASSERT_EQUAL( 1.99999999999999f, 2.0, "Float/double - relaxed check" ); WIN_ASSERT_EQUAL( 2.0, 1.99999999999999f, "Double/float - relaxed check" );
|User Mode||Kernel Mode|
|Header||Declared in winunit.h||N/A|
|Library||Link to cfix.lib||N/A|
Requires cl version 14.00 (VisualStudio 2005) or better.