00001
00002
00003 #ifndef REPORTER_H
00004 #define REPORTER_H
00005
00006
00007
00008 #include <string>
00009 #include <map>
00010
00011 namespace Anaphe {
00012
00013
00040 class Reporter
00041 {
00042 public:
00043 Reporter(void);
00044 ~Reporter(void);
00045
00046 public:
00048 bool report(const bool& with_printout) const;
00050 void setTitle(const std::string&);
00052 void clear(void);
00054 void keep(const std::string&, const bool& ex, const bool& ob);
00056 void keep(const std::string&, const int& ex, const int& ob);
00058 void keep(const std::string&, const float& ex, const float& ob);
00060 void keep(const std::string&, const double& ex, const double& ob);
00062 void keep(const std::string&, const char* ex, const char* ob);
00064 void keep(const std::string&, const std::string& ex, const std::string& ob);
00065
00066 private:
00067 void print(const std::string&, const std::string&,
00068 const std::string&, const int& = -1) const;
00070 bool veryClose(const float&, const float&) const;
00072 bool veryClose(const double&, const double&) const;
00073 std::string asString(const int&) const;
00074 std::string asString(const float&) const;
00075 std::string asString(const double& a) const;
00076 void reg(const std::string& name, const std::string& ex,
00077 const std::string& ob, const bool& res);
00078 void printHeader(void) const;
00079
00080 private:
00081 class Test
00082 {
00083 public:
00084 Test(void);
00085 Test(const std::string&, const std::string&, const std::string&, const bool&);
00086 const std::string& name(void) const {return mname;}
00087 const std::string& ex(void) const {return mex;}
00088 const std::string& ob(void) const {return mob;}
00089 const bool comp(void) const {return mcomp;}
00090 private:
00091 std::string mname;
00092 std::string mex;
00093 std::string mob;
00094 bool mcomp;
00095 };
00096 static const float F_PREC;
00097 static const double D_PREC;
00098 static const std::string H_TITLE;
00099 static const std::string H_EXP;
00100 static const std::string H_OBS;
00101 static const std::string H_FLAG;
00102 std::string title;
00103 std::map<int,Test> testList;
00104 typedef std::map<int,Test>::const_iterator TestIt;
00105 unsigned int widest_title;
00106 unsigned int widest_ob;
00107 unsigned int widest_ex;
00108 int nt;
00109
00110 };
00111
00112
00113
00114 }
00115
00116
00117 #endif // REPORTER_H