AdditionalMessage.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef CPPUNIT_ADDITIONALMESSAGE_H
  2. #define CPPUNIT_ADDITIONALMESSAGE_H
  3. #include <cppunit/Message.h>
  4. CPPUNIT_NS_BEGIN
  5. /*! \brief An additional Message for assertions.
  6. * \ingroup CreatingNewAssertions
  7. *
  8. * Provides a implicit constructor that takes a single string. This allow this
  9. * class to be used as the message arguments in macros.
  10. *
  11. * The constructed object is either a Message with a single detail string if
  12. * a string was passed to the macro, or a copy of the Message passed to the macro.
  13. *
  14. * Here is an example of usage:
  15. * \code
  16. *
  17. * void checkStringEquals( const std::string &expected,
  18. * const std::string &actual,
  19. * const CppUnit::SourceLine &sourceLine,
  20. * const CppUnit::AdditionalMessage &message );
  21. *
  22. * #define XTLUT_ASSERT_STRING_EQUAL_MESSAGE( expected, actual, message ) \
  23. * ::XtlUt::Impl::checkStringEquals( ::Xtl::toString(expected), \
  24. * ::Xtl::toString(actual), \
  25. * CPPUNIT_SOURCELINE(), \
  26. * message )
  27. * \endcode
  28. *
  29. * In the previous example, the user can specify a simple string for \a message,
  30. * or a complex Message object.
  31. *
  32. * \see Message
  33. */
  34. class CPPUNIT_API AdditionalMessage : public Message
  35. {
  36. public:
  37. typedef Message SuperClass;
  38. /// Constructs an empty Message.
  39. AdditionalMessage();
  40. /*! \brief Constructs a Message with the specified detail string.
  41. * \param detail1 Detail string of the message. If empty, then it is not added.
  42. */
  43. AdditionalMessage( const std::string &detail1 );
  44. /*! \brief Constructs a Message with the specified detail string.
  45. * \param detail1 Detail string of the message. If empty, then it is not added.
  46. */
  47. AdditionalMessage( const char *detail1 );
  48. /*! \brief Constructs a copy of the specified message.
  49. * \param other Message to copy.
  50. */
  51. AdditionalMessage( const Message &other );
  52. /*! \brief Assignment operator.
  53. * \param other Message to copy.
  54. * \return Reference on this object.
  55. */
  56. AdditionalMessage &operator =( const Message &other );
  57. private:
  58. };
  59. CPPUNIT_NS_END
  60. #endif // CPPUNIT_ADDITIONALMESSAGE_H