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>
|
|
|
|
|
2017-04-19 06:30:54 +08:00
|
|
|
#define xlnt_assert(expression) do\
|
2017-04-14 02:51:35 +08:00
|
|
|
{\
|
|
|
|
try { if (expression) break; }\
|
|
|
|
catch (...) {}\
|
2017-04-19 06:30:54 +08:00
|
|
|
throw xlnt::exception("test failed");\
|
2017-04-14 02:51:35 +08:00
|
|
|
} while (false)
|
|
|
|
|
2017-04-19 06:30:54 +08:00
|
|
|
#define xlnt_assert_throws_nothing(expression) do\
|
2017-04-14 02:51:35 +08:00
|
|
|
{\
|
|
|
|
try { expression; break; }\
|
|
|
|
catch (...) {}\
|
2017-04-19 06:30:54 +08:00
|
|
|
throw xlnt::exception("test failed");\
|
2017-04-14 02:51:35 +08:00
|
|
|
} while (false)
|
|
|
|
|
2017-04-19 06:30:54 +08:00
|
|
|
#define xlnt_assert_throws(expression, exception_type) do\
|
2017-04-14 02:51:35 +08:00
|
|
|
{\
|
|
|
|
try { expression; }\
|
|
|
|
catch (exception_type) { break; }\
|
2017-04-19 06:30:54 +08:00
|
|
|
catch (...) {}\
|
|
|
|
throw xlnt::exception("test failed");\
|
2017-04-14 02:51:35 +08:00
|
|
|
} while (false)
|
|
|
|
|
2017-04-19 06:30:54 +08:00
|
|
|
#define xlnt_assert_equals(left, right) xlnt_assert(left == right)
|
|
|
|
#define xlnt_assert_differs(left, right) xlnt_assert(left != right)
|
|
|
|
#define xlnt_assert_delta(left, right, delta) xlnt_assert(std::abs(left - right) <= delta)
|