WinUnit::ToString
Template for which an explicit specialization may be provided in order to enable cfix to obtain a string representation of an object for use in assertion messages.
namespace WinUnit { template< typename T > inline const TCHAR* ToString( __in const T& Object, __inout_ecount( BufferCch ) PTSTR Buffer, __in size_t BufferCch ) }
[in] Object: The object for which the string representation is to be created.
[in] Buffer: Buffer that may be used as storage for the string representation.
[in] BufferCch: Size of the buffer, in TCHARs.
The string representation. The pointer returned must either point to static storage or to the buffer passed as second parameter.
When WIN_ASSERT_EQUAL is used to compare two non-prmitive objects and the check fails, cfix generates an appropriate error message. To have this error message include a proper string representation of the objects being compared, you can -- optionally -- provide an appropriate explicit template specialization of WinUnit::ToString.
Note that this differs from the cfic C++ API, which invokes operator<< on an object to obtain its string representation.
class Foo { ... }; template<> const TCHAR* WinUnit::ToString( __in const Foo& Object, __inout_ecount( BufferCch ) PTSTR Buffer, __in size_t BufferCch ) { StringCchPrintf( Buffer, BufferCch, ... ); return Buffer; }