00001 #ifndef TEST_HPP_INCLUDED
00002 #define TEST_HPP_INCLUDED
00003
00004 #include <string>
00005
00006 #include "xmlrpc-c/girerr.hpp"
00007 using girerr::error;
00008
00009 class testSuite {
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 public:
00025 int tests,failures;
00026
00027 virtual ~testSuite();
00028
00029 void run(unsigned int const indentation);
00030
00031 virtual void runtests(unsigned int const) {
00032 throw(error("test suite does not have a runtests() method"));
00033 };
00034 virtual std::string suiteName() {
00035 return "unnamed test suite";
00036 }
00037 };
00038
00039
00040
00041 void
00042 logFailedTest(const char * const fileName,
00043 unsigned int const lineNum,
00044 const char * const statement);
00045
00046 error
00047 fileLineError(std::string const filename,
00048 unsigned int const lineNumber,
00049 std::string const description);
00050
00051 #define TEST(statement) \
00052 do {tests++; \
00053 if (!(statement)) { \
00054 logFailedTest(__FILE__, __LINE__, #statement); \
00055 failures++;} \
00056 } while (0)
00057
00058
00059 #define TEST_PASSED() \
00060 do { } while (0)
00061
00062 #define TEST_FAILED(reason) \
00063 do { \
00064 logFailedTest(__FILE__, __LINE__, (reason)); \
00065 } while (0)
00066
00067 #define EXPECT_ERROR(statement) \
00068 do { try { statement } catch (error) {break;} \
00069 throw(fileLineError(__FILE__, __LINE__, "Expected error; didn't get one")); \
00070 } while (0)
00071
00072 #define trickToStraightenOutEmacsIndentation \
00073 ;
00074
00075 #endif