X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fresult.hpp;h=0c78b9980f5469eb2a31ac235b796c36237fe180;hb=c262353965b12ae1ba585e3d71344c1533401010;hp=784ae72bbd12d7bb4e9de4f9360b56ba8a39af00;hpb=97b73d47e6a3d5729ba13304ff355a737a34f1b4;p=awesomized%2Flibmemcached diff --git a/libtest/result.hpp b/libtest/result.hpp index 784ae72b..0c78b998 100644 --- a/libtest/result.hpp +++ b/libtest/result.hpp @@ -37,78 +37,46 @@ #pragma once #include - -namespace libtest { - -class __test_result : public std::exception -{ -public: - __test_result(const char *file, int line, const char *func); - - int line() - { - return _line; - } - - const char* file() - { - return _file; - } - - const char* func() - { - return _func; - } - -private: - int _line; - const char* _file; - const char* _func; -}; - -class __success : public __test_result -{ -public: - __success(const char *file, int line, const char *func); - - const char* what() const throw() - { - return "SUCCESS"; - } - -private: -}; - -class __skipped : public __test_result -{ -public: - __skipped(const char *file, int line, const char *func); - - const char* what() const throw() - { - return "SKIPPED"; - } - -private: -}; - -class __failure : public __test_result -{ -public: - __failure(const char *file, int line, const char *func, const std::string&); - - const char* what() const throw() - { - return _error_message; - } - -private: - char _error_message[BUFSIZ]; -}; - - -} // namespace libtest +#include +#include +#include +#include +#include #define _SUCCESS throw libtest::__success(LIBYATL_DEFAULT_PARAM) -#define SKIP throw libtest::__skipped(LIBYATL_DEFAULT_PARAM) -#define FAIL(__mesg) throw libtest::__failure(LIBYATL_DEFAULT_PARAM, __mesg) + +#define SKIP(...) \ +do \ +{ \ + throw libtest::__skipped(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \ +} while (0) + +#define FAIL(...) \ +do \ +{ \ + throw libtest::__failure(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \ +} while (0) + +#define FATAL(...) \ +do \ +{ \ + throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \ +} while (0) + +#define FATAL_IF(__expression, ...) \ +do \ +{ \ + if ((__expression)) { \ + throw libtest::fatal(LIBYATL_DEFAULT_PARAM, (#__expression)); \ + } \ +} while (0) + +#define FATAL_IF_(__expression, ...) \ +do \ +{ \ + if ((__expression)) { \ + throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \ + } \ +} while (0) + +#define fatal_assert(__assert) if((__assert)) {} else { throw libtest::fatal(LIBYATL_DEFAULT_PARAM, #__assert); }