CFIXCC_ASSERT_LESS and CFIXCC_ASSERT_LESS_OR_EQUAL allow typesafe comparison of values. Failed comparisons are treated as a failure, i.e. in the same manner as a failed CFIX_ASSERT. The benefit over using CFIX_ASSERT( Expected < Actual )/CFIX_ASSERT( Expected <= Actual ) is that the expected and actual value will be visible in the failure report.
void CFIXCC_ASSERT_LESS( __in T Expected, __in T Actual ); void CFIXCC_ASSERT_LESS_OR_EQUAL( __in T Expected, __in T Actual );
T can be any type, but the types of both values must be compatible. See discussion below.
The way the comparison is conducted depends on the type of the two values.
- Primitive integer objects are compared using the builtin < [<=] operator.
- Pointers are checked for address inequality. An exception to this are C strings (char*, const char*, wchar_t*, const wchar_t*). Such strings will be wrapped by std::string and std::wstring objects respectively, and operator< [operator<=] of std::string or std::wstring will be invoked. That is, a value-comparison is conducted.
- For non-primitive, non-pointer types, i.e. objects of a custom class, operator< [operator<=] of the respective class is invoked.
CFIXCC_ASSERT_LESS( 1, 2 ); CFIXCC_ASSERT_LESS( L"a", L"b" ); CFIXCC_ASSERT_LESS_OR_EQUAL( -1, 0 ); CFIXCC_ASSERT_LESS_OR_EQUAL( -1, -1 );