00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MUNITTEST_H
00021 #define MUNITTEST_H
00022
00023 #include <iostream>
00024 using std::cout;
00025 using std::endl;
00026
00027 #include <mstring.h>
00028 using mstring::MString;
00029 using mstring::MStringList;
00030
00031
00034 namespace munittest {
00035
00040 class MUnittest{
00041 public:
00043 MUnittest(const MString& unitName);
00044 ~MUnittest();
00045
00050 void begin(const MString& title);
00051
00054 bool test(bool result, const MString& failureComment = MString());
00056 bool test(char result, char expected);
00058 bool test(int result, int expected);
00060 bool test(long result, long expected);
00062 bool test(uint result, uint expected);
00064 bool test(ulong result, ulong expected);
00066 bool test(float result, float expected);
00068 bool test(double result, double expected);
00070 bool test(const MString& result);
00072 bool test(const MString& result, const MString& expected);
00074 bool test(const MStringList& result, const MStringList& expected);
00075
00077 void comment(const MString& comment) const;
00078
00081 bool totals();
00082
00084 void setExitOnError(bool exitOnError);
00086 bool exitOnError() const;
00087
00088
00089 private:
00090
00091
00092 void initialize();
00093
00094 void endTest();
00095
00096
00097
00098 static const int WIDTH;
00099 static const int INDENT;
00100
00101 const MString _unitName;
00102
00103 uint _totalTests, _passedTests;
00104
00105 uint _totalCalls, _passedCalls;
00106
00107 bool _exitOnError;
00108
00109 MString _title;
00110 };
00111
00112 }
00113
00114 #endif //MUNITTEST_H