]> git.stg.codes - stg.git/blobdiff - tests/tut/tut_result.hpp
TUT framework updated to svn version
[stg.git] / tests / tut / tut_result.hpp
index 5731802cb08ec61a1e49a9add460c83685e6ce17..e96078595c877daf969471d14dcb22b891e0f982 100644 (file)
@@ -1,11 +1,42 @@
 #ifndef TUT_RESULT_H_GUARD
 #define TUT_RESULT_H_GUARD
+#include <tut/tut_config.hpp>
 
 #include <string>
 
+#if defined(TUT_USE_RTTI)
+#if (defined(_MSC_VER) && !defined(_CPPRTTI)) || (defined(__GNUC__) && !defined(__GXX_RTTI))
+#undef TUT_USE_RTTI
+#endif
+#endif
+
+#if defined(TUT_USE_RTTI)
+#include <typeinfo>
+#endif
+
 namespace tut
 {
 
+#if defined(TUT_USE_RTTI)
+template<typename T>
+inline std::string type_name(const T& t)
+{
+    return typeid(t).name();
+}
+#else
+template<typename T>
+inline std::string type_name(const T& t)
+{
+    return "Unknown type, RTTI disabled";
+}
+
+inline std::string type_name(const std::exception&)
+{
+    return "Unknown std::exception, RTTI disabled";
+}
+#endif
+
+
 #if defined(TUT_USE_POSIX)
 struct test_result_posix
 {
@@ -14,11 +45,18 @@ struct test_result_posix
     {
     }
 
+    virtual ~test_result_posix()
+    {
+    }
+
     pid_t pid;
 };
 #else
 struct test_result_posix
 {
+    virtual ~test_result_posix()
+    {
+    }
 };
 #endif
 
@@ -46,22 +84,19 @@ struct test_result : public test_result_posix
     std::string name;
 
     /**
-     * ok - test finished successfully
-     * fail - test failed with ensure() or fail() methods
-     * ex - test throwed an exceptions
-     * warn - test finished successfully, but test destructor throwed
-     * term - test forced test application to terminate abnormally
+     * result of a test 
      */
     enum result_type
     {
-        ok,
-        fail,
-        ex,
-        warn,
-        term,
-        ex_ctor,
-        rethrown,
-        dummy
+        ok,       ///< test finished successfully
+        fail,     ///< test failed with ensure() or fail() methods
+        ex,       ///< test throwed an exceptions
+        warn,     ///< test finished successfully, but test destructor throwed
+        term,     ///< test forced test application to terminate abnormally
+        ex_ctor,  ///< 
+        rethrown, ///< 
+        skipped,  ///< 
+        dummy     ///< 
     };
 
     result_type result;
@@ -76,8 +111,12 @@ struct test_result : public test_result_posix
      * Default constructor.
      */
     test_result()
-        : test(0),
-          result(ok)
+        : group(),
+          test(0),
+          name(),
+          result(ok),
+          message(),
+          exception_typeid()
     {
     }
 
@@ -89,7 +128,9 @@ struct test_result : public test_result_posix
         : group(grp),
           test(pos),
           name(test_name),
-          result(res)
+          result(res),
+          message(),
+          exception_typeid()
     {
     }
 
@@ -104,7 +145,7 @@ struct test_result : public test_result_posix
           name(test_name),
           result(res),
           message(ex.what()),
-          exception_typeid(typeid(ex).name())
+          exception_typeid(type_name(ex))
     {
     }
 
@@ -122,6 +163,10 @@ struct test_result : public test_result_posix
           exception_typeid(ex_typeid)
     {
     }
+
+    virtual ~test_result()
+    {
+    }
 };
 
 }