CppUnit project page FAQ

Public Types | Public Member Functions
AdditionalMessage Class Reference

An additional Message for assertions.Provides a implicit constructor that takes a single string. This allow this class to be used as the message arguments in macros. More...

#include <AdditionalMessage.h>

Inheritance diagram for AdditionalMessage:
Inheritance graph
[legend]
Collaboration diagram for AdditionalMessage:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Message SuperClass

Public Member Functions

 AdditionalMessage ()
 Constructs an empty Message.
 AdditionalMessage (const std::string &detail1)
 Constructs a Message with the specified detail string.
 AdditionalMessage (const char *detail1)
 Constructs a Message with the specified detail string.
 AdditionalMessage (const Message &other)
 Constructs a copy of the specified message.
AdditionalMessageoperator= (const Message &other)
 Assignment operator.
- Public Member Functions inherited from Message
 Message ()
 Message (const Message &other)
 Message (const std::string &shortDescription)
 Message (const std::string &shortDescription, const std::string &detail1)
 Message (const std::string &shortDescription, const std::string &detail1, const std::string &detail2)
 Message (const std::string &shortDescription, const std::string &detail1, const std::string &detail2, const std::string &detail3)
 ~Message ()
const std::string & shortDescription () const
 Returns the short description.
int detailCount () const
 Returns the number of detail string.
std::string detailAt (int index) const
 Returns the detail at the specified index.
std::string details () const
 Returns a string that represents a list of the detail strings.
void clearDetails ()
 Removes all detail strings.
void addDetail (const std::string &detail)
 Adds a single detail string.
void addDetail (const std::string &detail1, const std::string &detail2)
 Adds two detail strings.
void addDetail (const std::string &detail1, const std::string &detail2, const std::string &detail3)
 Adds three detail strings.
void addDetail (const Message &message)
 Adds the detail strings of the specified message.
void setShortDescription (const std::string &shortDescription)
 Sets the short description.
bool operator== (const Message &other) const
 Tests if a message is identical to another one.
bool operator!= (const Message &other) const
 Tests if a message is different from another one.

Detailed Description

An additional Message for assertions.

Provides a implicit constructor that takes a single string. This allow this class to be used as the message arguments in macros.

The constructed object is either a Message with a single detail string if a string was passed to the macro, or a copy of the Message passed to the macro.

Here is an example of usage:

void checkStringEquals( const std::string &expected,
const std::string &actual,
const CppUnit::SourceLine &sourceLine,
const CppUnit::AdditionalMessage &message );
#define XTLUT_ASSERT_STRING_EQUAL_MESSAGE( expected, actual, message ) \
::XtlUt::Impl::checkStringEquals( ::Xtl::toString(expected), \
::Xtl::toString(actual), \
CPPUNIT_SOURCELINE(), \
message )

In the previous example, the user can specify a simple string for message, or a complex Message object.

See also:
Message

Member Typedef Documentation


Constructor & Destructor Documentation

CPPUNIT_NS_BEGIN AdditionalMessage::AdditionalMessage ( )

Constructs an empty Message.

AdditionalMessage::AdditionalMessage ( const std::string &  detail1)

Constructs a Message with the specified detail string.

Parameters:
detail1Detail string of the message. If empty, then it is not added.
AdditionalMessage::AdditionalMessage ( const char *  detail1)

Constructs a Message with the specified detail string.

Parameters:
detail1Detail string of the message. If empty, then it is not added.
AdditionalMessage::AdditionalMessage ( const Message other)

Constructs a copy of the specified message.

Parameters:
otherMessage to copy.

Member Function Documentation

AdditionalMessage & AdditionalMessage::operator= ( const Message other)

Assignment operator.

Parameters:
otherMessage to copy.
Returns:
Reference on this object.

Reimplemented from Message.


The documentation for this class was generated from the following files:

Send comments to:
CppUnit Developers