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
stringrepresenting the input argument of typeT. The default implementation creates the outputstringby creating astd::OStringStreamand using its<<operator.
Protected/Private Methods
None.
Attributes
None.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
