summaryrefslogtreecommitdiff
path: root/include/cppunit/TestAssert.h
diff options
context:
space:
mode:
authorBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-04-29 13:09:16 +0000
committerBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-04-29 13:09:16 +0000
commitb08ecaecc1e39b7b01e02b7b73559d8b34ff46a5 (patch)
treebf1ed1e3680cb0256e73336e22fb70c692524fcb /include/cppunit/TestAssert.h
parent5ce1a68589aa3ea4f9ee255cfecc94cc1730c6fa (diff)
downloadcppunit-b08ecaecc1e39b7b01e02b7b73559d8b34ff46a5.tar.gz
Merged Baptiste Lepilleurs CppUnitW 1.2.
Some differences: TypeInfo stuff (in TestSuite) compiled in only if USE_TYPEINFO is set. TestSuite.getTests now returns a const ref instead of taking a ref as param. Removed auto_ptr stuff from TestFactoryRegistry: auto_ptr cannot be used in containers.
Diffstat (limited to 'include/cppunit/TestAssert.h')
-rw-r--r--include/cppunit/TestAssert.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h
new file mode 100644
index 0000000..f67649e
--- /dev/null
+++ b/include/cppunit/TestAssert.h
@@ -0,0 +1,81 @@
+#ifndef CPPUNIT_TESTASSERT_H
+#define CPPUNIT_TESTASSERT_H
+
+#include <string>
+
+#ifndef CPPUNIT_EXCEPTION_H
+#include "Exception.h"
+#endif
+
+namespace CppUnit {
+
+ /*! \brief This class represents
+ */
+ class TestAssert
+ {
+ public:
+ virtual ~TestAssert() {}
+
+ static void assertImplementation(
+ bool condition,
+ std::string conditionExpression = "",
+ long lineNumber = Exception::UNKNOWNLINENUMBER,
+ std::string fileName = Exception::UNKNOWNFILENAME);
+
+ static void assertEquals (long expected,
+ long actual,
+ long lineNumber = Exception::UNKNOWNLINENUMBER,
+ std::string fileName = Exception::UNKNOWNFILENAME);
+
+ static void assertEquals (double expected,
+ double actual,
+ double delta,
+ long lineNumber = Exception::UNKNOWNLINENUMBER,
+ std::string fileName = Exception::UNKNOWNFILENAME);
+
+ static std::string notEqualsMessage (long expected,
+ long actual);
+
+ static std::string notEqualsMessage (double expected,
+ double actual);
+ };
+
+
+/** A set of macros which allow us to get the line number
+ * and file name at the point of an error.
+ * Just goes to show that preprocessors do have some
+ * redeeming qualities.
+ */
+#define CPPUNIT_SOURCEANNOTATION
+
+#ifdef CPPUNIT_SOURCEANNOTATION
+
+ #undef assert
+ #define assert(condition)\
+ (CppUnit::TestAssert::assertImplementation ((condition),(#condition),\
+ __LINE__, __FILE__))
+
+#else
+
+ #undef assert
+ #define assert(condition)\
+ (CppUnit::TestAssert::assertImplementation ((condition),"",\
+ __LINE__, __FILE__))
+
+#endif
+
+
+/// Macro for primitive value comparisons
+#define assertDoublesEqual(expected,actual,delta)\
+(CppUnit::TestAssert::assertEquals ((expected),\
+ (actual),(delta),__LINE__,__FILE__))
+
+/// Macro for primitive value comparisons
+#define assertLongsEqual(expected,actual)\
+(CppUnit::TestAssert::assertEquals ((expected),\
+ (actual),__LINE__,__FILE__))
+
+
+} // namespace CppUnit
+
+#endif // CPPUNIT_TESTASSERT_H