2017-04-14 02:51:35 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-14 10:38:26 +08:00
|
|
|
#include <cmath>
|
2017-04-14 02:51:35 +08:00
|
|
|
#include <exception>
|
|
|
|
|
|
|
|
#define assert(expression) do\
|
|
|
|
{\
|
|
|
|
try { if (expression) break; }\
|
|
|
|
catch (...) {}\
|
|
|
|
throw std::exception();\
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define assert_throws_nothing(expression) do\
|
|
|
|
{\
|
|
|
|
try { expression; break; }\
|
|
|
|
catch (...) {}\
|
|
|
|
throw std::exception();\
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define assert_throws(expression, exception_type) do\
|
|
|
|
{\
|
|
|
|
try { expression; }\
|
|
|
|
catch (exception_type) { break; }\
|
|
|
|
throw std::exception();\
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define assert_equals(left, right) assert(left == right)
|
|
|
|
#define assert_differs(left, right) assert(left != right)
|
|
|
|
#define assert_delta(left, right, delta) assert(std::abs(left - right) <= delta)
|