#pragma once #include #include #include namespace adminive::test { inline void check(bool condition, const char* expression, const char* file, int line) { if(condition) { return; } std::cerr << file << ':' << line << ": check failed: " << expression << '\n'; std::abort(); } template bool throws_as(Function&& function) { try { std::forward(function)(); } catch(const Exception&) { return true; } return false; } } #define ADMINIVE_CHECK(expression) ::adminive::test::check(static_cast(expression), #expression, __FILE__, __LINE__) #define ADMINIVE_CHECK_THROWS_AS(expression, exception) \ ADMINIVE_CHECK((::adminive::test::throws_as([&] { static_cast(expression); })))