summaryrefslogtreecommitdiff
path: root/include/cppunit/Asserter.h
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-05 21:52:20 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-06 16:38:21 +0200
commit4dbaa35920fa376c48eedf8cc3440b3965a01caa (patch)
treea57b25baae810fba7594b764628405fada72bac1 /include/cppunit/Asserter.h
parent7902eb988d167b6cddd88b6c5be4385b203080eb (diff)
downloadcppunit-feature/new_assert_macros.tar.gz
add new assertion macros for <, <=, > and >=feature/new_assert_macros
Now we support the following new macros: - CPPUNIT_ASSERT_LESS - CPPUNIT_ASSERT_GREATER - CPPUNIT_ASSERT_LESSEQUAL - CPPUNIT_ASSERT_GREATEREQUAL
Diffstat (limited to 'include/cppunit/Asserter.h')
-rw-r--r--include/cppunit/Asserter.h104
1 files changed, 103 insertions, 1 deletions
diff --git a/include/cppunit/Asserter.h b/include/cppunit/Asserter.h
index 94dadaa..1a333d2 100644
--- a/include/cppunit/Asserter.h
+++ b/include/cppunit/Asserter.h
@@ -76,16 +76,55 @@ struct Asserter
std::string message,
const SourceLine &sourceLine = SourceLine() );
- /*! \brief Returns a expected value string for a message.
+ /*! \brief Returns a expected value string for a message, case equal than
* Typically used to create 'not equal' message, or to check that a message
* contains the expected content when writing unit tests for your custom
* assertions.
*
* \param expectedValue String that represents the expected value.
* \return \a expectedValue prefixed with "Expected: ".
+ * \deprecated Use makeExpectedEqual instead
* \see makeActual().
*/
static std::string CPPUNIT_API makeExpected( const std::string &expectedValue );
+ /*! \brief Returns a expected value string for a message, case equal than
+ * Typically used to create 'not equal' message, or to check that a message
+ * contains the expected content when writing unit tests for your custom
+ * assertions.
+ *
+ * \param expectedValue String that represents the expected value.
+ * \return \a expectedValue prefixed with "Expected: ".
+ * \see makeActual().
+ */
+ static std::string CPPUNIT_API makeExpectedEqual( const std::string &expectedValue );
+ /*! \brief Returns a expected value string for a message, case less than.
+ *
+ * \param expectedValue String that represents the expected value.
+ * \return \a expectedValue prefixed with "Expected less than: ".
+ * \see makeExpectedEqual().
+ */
+ static std::string CPPUNIT_API makeExpectedLess( const std::string &expectedValue );
+ /*! \brief Returns a expected value string for a message, case less or equal than.
+ *
+ * \param expectedValue String that represents the expected value.
+ * \return \a expectedValue prefixed with "Expected: ".
+ * \see makeExpectedEqual().
+ */
+ static std::string CPPUNIT_API makeExpectedLessEqual( const std::string &expectedValue );
+ /*! \brief Returns a expected value string for a message, case greater than.
+ *
+ * \param expectedValue String that represents the expected value.
+ * \return \a expectedValue prefixed with "Expected: ".
+ * \see makeExpectedEqual().
+ */
+ static std::string CPPUNIT_API makeExpectedGreater( const std::string &expectedValue );
+ /*! \brief Returns a expected value string for a message, greater or equal than.
+ *
+ * \param expectedValue String that represents the expected value.
+ * \return \a expectedValue prefixed with "Expected: ".
+ * \see makeExpectedEqual().
+ */
+ static std::string CPPUNIT_API makeExpectedGreaterEqual( const std::string &expectedValue );
/*! \brief Returns an actual value string for a message.
* Typically used to create 'not equal' message, or to check that a message
@@ -98,11 +137,19 @@ struct Asserter
*/
static std::string CPPUNIT_API makeActual( const std::string &actualValue );
+ /*!
+ * \deprecated Use makeMessage instead
+ */
static Message CPPUNIT_API makeNotEqualMessage( const std::string &expectedValue,
const std::string &actualValue,
const AdditionalMessage &additionalMessage = AdditionalMessage(),
const std::string &shortDescription = "equality assertion failed");
+ static Message CPPUNIT_API makeMessage( const std::string &expectedValue,
+ const std::string &actualValue,
+ const std::string &shortDescription,
+ const AdditionalMessage &additionalMessage = AdditionalMessage());
+
/*! \brief Throws an Exception with the specified message and location.
* \param expected Text describing the expected value.
* \param actual Text describing the actual value.
@@ -118,6 +165,61 @@ struct Asserter
std::string shortDescription = "equality assertion failed" );
/*! \brief Throws an Exception with the specified message and location.
+ * \param expected Text describing the expected value.
+ * \param actual Text describing the actual value.
+ * \param sourceLine Location of the assertion.
+ * \param additionalMessage Additional message. Usually used to report
+ * what are the differences between the expected and actual value.
+ * \param shortDescription Short description for the failure message.
+ */
+ static void CPPUNIT_API failNotLess( std::string expected,
+ std::string actual,
+ const SourceLine &sourceLine,
+ const AdditionalMessage &additionalMessage = AdditionalMessage(),
+ std::string shortDescription = "less assertion failed" );
+
+ /*! \brief Throws an Exception with the specified message and location.
+ * \param expected Text describing the expected value.
+ * \param actual Text describing the actual value.
+ * \param sourceLine Location of the assertion.
+ * \param additionalMessage Additional message. Usually used to report
+ * what are the differences between the expected and actual value.
+ * \param shortDescription Short description for the failure message.
+ */
+ static void CPPUNIT_API failNotGreater( std::string expected,
+ std::string actual,
+ const SourceLine &sourceLine,
+ const AdditionalMessage &additionalMessage = AdditionalMessage(),
+ std::string shortDescription = "greater assertion failed" );
+
+ /*! \brief Throws an Exception with the specified message and location.
+ * \param expected Text describing the expected value.
+ * \param actual Text describing the actual value.
+ * \param sourceLine Location of the assertion.
+ * \param additionalMessage Additional message. Usually used to report
+ * what are the differences between the expected and actual value.
+ * \param shortDescription Short description for the failure message.
+ */
+ static void CPPUNIT_API failNotLessEqual( std::string expected,
+ std::string actual,
+ const SourceLine &sourceLine,
+ const AdditionalMessage &additionalMessage = AdditionalMessage(),
+ std::string shortDescription = "less equal assertion failed" );
+
+ /*! \brief Throws an Exception with the specified message and location.
+ * \param expected Text describing the expected value.
+ * \param actual Text describing the actual value.
+ * \param sourceLine Location of the assertion.
+ * \param additionalMessage Additional message. Usually used to report
+ * what are the differences between the expected and actual value.
+ * \param shortDescription Short description for the failure message.
+ */
+ static void CPPUNIT_API failNotGreaterEqual( std::string expected,
+ std::string actual,
+ const SourceLine &sourceLine,
+ const AdditionalMessage &additionalMessage = AdditionalMessage(),
+ std::string shortDescription = "greater equal assertion failed" ); /*! \brief Throws an Exception with the specified message and location.
+
* \param shouldFail if \c true then the exception is thrown. Otherwise
* nothing happen.
* \param expected Text describing the expected value.