X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/3156083fd0c328d46be22536720ae33e1ab48090..f002c1b7709097d5405d672e7b07c5f00c9b3e36:/tests/tut/tut_exception.hpp diff --git a/tests/tut/tut_exception.hpp b/tests/tut/tut_exception.hpp index c5c88cb2..1ebea341 100644 --- a/tests/tut/tut_exception.hpp +++ b/tests/tut/tut_exception.hpp @@ -12,7 +12,7 @@ namespace tut */ struct tut_error : public std::exception { - tut_error(const std::string& msg) + explicit tut_error(const std::string& msg) : err_msg(msg) { } @@ -22,6 +22,11 @@ struct tut_error : public std::exception return test_result::ex; } + virtual std::string type() const + { + return "tut::tut_error"; + } + const char* what() const throw() { return err_msg.c_str(); @@ -32,8 +37,9 @@ struct tut_error : public std::exception } private: + void operator=(const tut_error &); - std::string err_msg; + const std::string err_msg; }; /** @@ -41,23 +47,48 @@ private: */ struct no_such_group : public tut_error { - no_such_group(const std::string& grp) + explicit no_such_group(const std::string& grp) : tut_error(grp) { } + virtual std::string type() const + { + return "tut::no_such_group"; + } + ~no_such_group() throw() { } }; +/** + * Test not found exception. + */ +struct no_such_test : public tut_error +{ + explicit no_such_test(const std::string& grp) + : tut_error(grp) + { + } + + virtual std::string type() const + { + return "tut::no_such_test"; + } + + ~no_such_test() throw() + { + } +}; + /** * Internal exception to be throwed when * test constructor has failed. */ struct bad_ctor : public tut_error { - bad_ctor(const std::string& msg) + explicit bad_ctor(const std::string& msg) : tut_error(msg) { } @@ -67,6 +98,11 @@ struct bad_ctor : public tut_error return test_result::ex_ctor; } + virtual std::string type() const + { + return "tut::bad_ctor"; + } + ~bad_ctor() throw() { } @@ -77,7 +113,7 @@ struct bad_ctor : public tut_error */ struct failure : public tut_error { - failure(const std::string& msg) + explicit failure(const std::string& msg) : tut_error(msg) { } @@ -87,6 +123,11 @@ struct failure : public tut_error return test_result::fail; } + virtual std::string type() const + { + return "tut::failure"; + } + ~failure() throw() { } @@ -97,7 +138,7 @@ struct failure : public tut_error */ struct warning : public tut_error { - warning(const std::string& msg) + explicit warning(const std::string& msg) : tut_error(msg) { } @@ -107,6 +148,11 @@ struct warning : public tut_error return test_result::warn; } + virtual std::string type() const + { + return "tut::warning"; + } + ~warning() throw() { } @@ -117,7 +163,7 @@ struct warning : public tut_error */ struct seh : public tut_error { - seh(const std::string& msg) + explicit seh(const std::string& msg) : tut_error(msg) { } @@ -127,6 +173,11 @@ struct seh : public tut_error return test_result::term; } + virtual std::string type() const + { + return "tut::seh"; + } + ~seh() throw() { } @@ -147,6 +198,11 @@ struct rethrown : public failure return test_result::rethrown; } + virtual std::string type() const + { + return "tut::rethrown"; + } + ~rethrown() throw() { } @@ -154,6 +210,28 @@ struct rethrown : public failure const test_result tr; }; +struct skipped : public tut_error +{ + explicit skipped(const std::string& msg) + : tut_error(msg) + { + } + + virtual test_result::result_type result() const + { + return test_result::skipped; + } + + virtual std::string type() const + { + return "tut::skipped"; + } + + ~skipped() throw() + { + } +}; + } #endif