X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/3156083fd0c328d46be22536720ae33e1ab48090..5056c7c504cad88d663296454d9f67a96ea2fbdd:/tests/tut/tut_result.hpp?ds=sidebyside diff --git a/tests/tut/tut_result.hpp b/tests/tut/tut_result.hpp index 5731802c..e9607859 100644 --- a/tests/tut/tut_result.hpp +++ b/tests/tut/tut_result.hpp @@ -1,11 +1,42 @@ #ifndef TUT_RESULT_H_GUARD #define TUT_RESULT_H_GUARD +#include #include +#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 +#endif + namespace tut { +#if defined(TUT_USE_RTTI) +template +inline std::string type_name(const T& t) +{ + return typeid(t).name(); +} +#else +template +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() + { + } }; }