CppUnit - The Unit Testing Library

CppUnit project page | FAQ

Static Public Member Functions | List of all members
assertion_traits< T > Struct Template Reference

Traits used by CPPUNIT_ASSERT* macros. More...

`#include <TestAssert.h>`

## Static Public Member Functions
static bool | equal (const T &x, const T &y)
static bool | less (const T &x, const T &y)
static bool | lessEqual (const T &x, const T &y)
static std::string | toString (const T &x)

## Detailed Description

template<class T>
struct assertion_traits< T >

Traits used by CPPUNIT_ASSERT* macros.

Here is an example of specialising these traits:

template<>
struct assertion_traits<std::string> // specialization for the std::string type
{
static bool equal( const std::string& x, const std::string& y )
{
return x == y;
}
static bool less( const std::string& x, const std::string& y )
{
return x < y;
}
static bool lessEqual( const std::string& x, const std::string& y )
{
return x <= y;
}
static std::string toString( const std::string& x )
{
std::string text = '"' + x + '"'; // adds quote around the string to see whitespace
OStringStream ost;
ost << text;
return ost.str();
}
};
assertion_traits
Traits used by CPPUNIT_ASSERT* macros.
Definition: TestAssert.h:56
assertion_traits::toString
static std::string toString(const T &x)
Definition: TestAssert.h:72
assertion_traits::equal
static bool equal(const T &x, const T &y)
Definition: TestAssert.h:57
assertion_traits::lessEqual
static bool lessEqual(const T &x, const T &y)
Definition: TestAssert.h:67
assertion_traits::less
static bool less(const T &x, const T &y)
Definition: TestAssert.h:62

## Member Function Documentation

## ◆ equal()

template<class T >

static bool assertion_traits< T >::equal | ( | const T & | x,
|  | const T & | y
| ) |  |
| inlinestatic

## ◆ less()

template<class T >

static bool assertion_traits< T >::less | ( | const T & | x,
|  | const T & | y
| ) |  |
| inlinestatic

## ◆ lessEqual()

template<class T >

static bool assertion_traits< T >::lessEqual | ( | const T & | x,
|  | const T & | y
| ) |  |
| inlinestatic

## ◆ toString()

template<class T >

static std::string assertion_traits< T >::toString | ( | const T & | x | ) |
| inlinestatic

The documentation for this struct was generated from the following file:

- TestAssert.h

| Send comments to: CppUnit Developers