tut logo

tut_result.hpp Source File


tut_result.hpp
1 #ifndef TUT_RESULT_H_GUARD
2 #define TUT_RESULT_H_GUARD
3 #include <tut/tut_config.hpp>
4 
5 #include <string>
6 
7 #if defined(TUT_USE_RTTI)
8 #if (defined(_MSC_VER) && !defined(_CPPRTTI)) || (defined(__GNUC__) && !defined(__GXX_RTTI))
9 #undef TUT_USE_RTTI
10 #endif
11 #endif
12 
13 #if defined(TUT_USE_RTTI)
14 #include <typeinfo>
15 #endif
16 
17 namespace tut
18 {
19 
20 #if defined(TUT_USE_RTTI)
21 template<typename T>
22 inline std::string type_name(const T& t)
23 {
24  return typeid(t).name();
25 }
26 #else
27 template<typename T>
28 inline std::string type_name(const T& t)
29 {
30  return "Unknown type, RTTI disabled";
31 }
32 
33 inline std::string type_name(const std::exception&)
34 {
35  return "Unknown std::exception, RTTI disabled";
36 }
37 #endif
38 
39 
40 #if defined(TUT_USE_POSIX)
41 struct test_result_posix
42 {
43  test_result_posix()
44  : pid(getpid())
45  {
46  }
47 
48  virtual ~test_result_posix()
49  {
50  }
51 
52  pid_t pid;
53 };
54 #else
56 {
57  virtual ~test_result_posix()
58  {
59  }
60 };
61 #endif
62 
70 {
74  std::string group;
75 
79  int test;
80 
84  std::string name;
85 
90  {
91  ok,
92  fail,
93  ex,
94  warn,
95  term,
96  ex_ctor,
97  rethrown,
98  skipped,
99  dummy
100  };
101 
102  result_type result;
103 
107  std::string message;
108  std::string exception_typeid;
109 
114  : group(),
115  test(0),
116  name(),
117  result(ok),
118  message(),
119  exception_typeid()
120  {
121  }
122 
126  test_result(const std::string& grp, int pos,
127  const std::string& test_name, result_type res)
128  : group(grp),
129  test(pos),
130  name(test_name),
131  result(res),
132  message(),
133  exception_typeid()
134  {
135  }
136 
140  test_result(const std::string& grp,int pos,
141  const std::string& test_name, result_type res,
142  const std::exception& ex)
143  : group(grp),
144  test(pos),
145  name(test_name),
146  result(res),
147  message(ex.what()),
148  exception_typeid(type_name(ex))
149  {
150  }
151 
154  test_result(const std::string& grp,int pos,
155  const std::string& test_name, result_type res,
156  const std::string& ex_typeid,
157  const std::string& msg)
158  : group(grp),
159  test(pos),
160  name(test_name),
161  result(res),
162  message(msg),
163  exception_typeid(ex_typeid)
164  {
165  }
166 
167  virtual ~test_result()
168  {
169  }
170 };
171 
172 }
173 
174 #endif
test_result()
Definition: tut_result.hpp:113
std::string group
Definition: tut_result.hpp:74
test_result(const std::string &grp, int pos, const std::string &test_name, result_type res, const std::string &ex_typeid, const std::string &msg)
Definition: tut_result.hpp:154
Definition: tut_exception.hpp:213
test_result(const std::string &grp, int pos, const std::string &test_name, result_type res, const std::exception &ex)
Definition: tut_result.hpp:140
test finished successfully
Definition: tut_result.hpp:91
result_type
Definition: tut_result.hpp:89
Definition: tut_exception.hpp:189
int test
Definition: tut_result.hpp:79
std::string name
Definition: tut_result.hpp:84
test finished successfully, but test destructor throwed
Definition: tut_result.hpp:94
test_result(const std::string &grp, int pos, const std::string &test_name, result_type res)
Definition: tut_result.hpp:126
test failed with ensure() or fail() methods
Definition: tut_result.hpp:92
std::string message
Definition: tut_result.hpp:107
Definition: tut_result.hpp:69
test forced test application to terminate abnormally
Definition: tut_result.hpp:95
test throwed an exceptions
Definition: tut_result.hpp:93
Definition: tut_result.hpp:55

All Rights Reserved. Generated on Wed Dec 18 2013 11:19:52 for TUT by doxygen 1.8.5