Name
assertion_traits
Description
The template
assertion_traits
(see Figure C-1) is
used by the CPPUNIT_ASSERT_EQUAL()
macro. The template is specialized for
different data types that are passed to the macro. For example, the
template specialization
assertion_traits<int>
is used when
CPPUNIT_ASSERT_EQUAL( )
takes arguments of type
int
.
The declaration of assertion_traits
is found in
TestAssert.h. It belongs to the namespace
CppUnit
.
Declaration
template<class T> struct assertion_traits<T>
Constructors/Destructors
None.
Public Methods
-
static bool equal(const T& x, const T& y)
A function template to compare two arguments of type
T
. The default implementation compares them using==
.-
static string toString(const T& x)
A function template to output a
string
representing the input argument of typeT
. The default implementation creates the outputstring
by creating astd::OStringStream
and using its<<
operator.
Protected/Private Methods
None.
Attributes
None.
Get Unit Test Frameworks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.