fluidvis
XUnit.h
1 #ifndef _SX_XUNIT_H_
2 #define _SX_XUNIT_H_
3 
9 #include <export/Export.h>
10 #include <sx/Log4SX.h>
11 
12 namespace sx {
13 
17  class XUnit {
18  private:
19 
25  Logger *logger;
26 
30  bool passed;
31 
35  XUnit(const XUnit &);
36 
40  XUnit &operator = (const XUnit &);
41 
45  template<class X>
46  void _INTERN_ASSERTEQUALS_(X v1, X v2) {
47  (*logger) << Annotation("assertEquals: ");
48  if(v1 == v2) {
49  (*logger) << Level(L_HARMLESS) << "success" << Logger::newLine();
50  } else {
51  (*logger) << Level(L_ERROR) << "fail: param1 is " << v1 << ", but param2 is " << v2 << Logger::newLine();
52  passed = false;
53  }
54  }
55 
56  public:
57 
64  EXL XUnit(Logger *logger);
65 
69  EXL ~XUnit();
70 
76  EXL void addMarkup(string comment);
77 
83  EXL void addAnnotation(string annotation);
84 
88  EXL void assertTrue(bool value);
89 
93  EXL void assertEquals(char v1, char v2);
94 
98  EXL void assertEquals(unsigned char v1, unsigned char v2);
99 
103  EXL void assertEquals(short v1, short v2);
104 
108  EXL void assertEquals(unsigned short v1, unsigned short v2);
109 
113  EXL void assertEquals(int v1, int v2);
114 
118  EXL void assertEquals(unsigned int v1, unsigned int v2);
119 
123  EXL void assertEquals(long v1, long v2);
124 
128  EXL void assertEquals(unsigned long v1, unsigned long v2);
129 
133  EXL void assertEquals(float v1, float v2);
134 
139  EXL void assertEquals(float v1, float v2, float epsilon);
140 
144  EXL void assertEquals(double v1, double v2);
145 
150  EXL void assertEquals(double v1, double v2, double epsilon);
151 
156  EXL void assertEquals(string v1, string v2);
157 
164  EXL void assertInputYes(string message);
165 
166  };
167 
168 }
169 
170 #endif
Definition: XUnit.h:17
EXL ~XUnit()
EXL void assertInputYes(string message)
EXL void addMarkup(string comment)
Definition: Log4SX.h:184
EXL void assertTrue(bool value)
EXL void assertEquals(char v1, char v2)
static EXL string newLine()
Definition: Log4SX.h:44
Definition: Log4SX.h:135
EXL void addAnnotation(string annotation)
Definition: Exception.h:13