12 const std::string& filename,
13 const std::string& lineNumber,
14 const std::string& condition,
15 const std::string& message);
23#define PH_ASSERT_MSG(condition, failMessage)\
28 ::ph::detail::output_assertion_message(\
29 std::string(__FILE__),\
30 std::to_string(__LINE__),\
31 std::string(#condition),\
32 std::string((failMessage)));\
34 ::ph::detail::on_assertion_failed();\
38#define PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, lowerBoundSymbol, upperBoundSymbol)\
39 (std::string(#value) + " = " + std::to_string(value) + ", asserted to be in range = " + \
40 lowerBoundSymbol + std::to_string(lowerBound) + ", " + std::to_string(upperBound) + upperBoundSymbol)
44#define PH_ASSERT_MSG(condition, message) PH_NO_OP()
45#define PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, lowerBoundSymbol, upperBoundSymbol) PH_NO_OP()
49#define PH_ASSERT(condition)\
50 PH_ASSERT_MSG(condition, "")
52#define PH_ASSERT_UNREACHABLE_SECTION()\
53 PH_ASSERT_MSG(false, "executing supposedly unreachable code")
55#define PH_ASSERT_EQ(a, b)\
56 PH_ASSERT_MSG(a == b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
58#define PH_ASSERT_NE(a, b)\
59 PH_ASSERT_MSG(a != b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
61#define PH_ASSERT_GT(a, b)\
62 PH_ASSERT_MSG(a > b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
64#define PH_ASSERT_LT(a, b)\
65 PH_ASSERT_MSG(a < b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
67#define PH_ASSERT_GE(a, b)\
68 PH_ASSERT_MSG(a >= b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
70#define PH_ASSERT_LE(a, b)\
71 PH_ASSERT_MSG(a <= b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
75#define PH_ASSERT_IN_RANGE(value, begin, end)\
76 PH_ASSERT_MSG(begin <= value && value < end, PH_INTERNAL_RANGE_MSG(value, begin, end, "[", ")"))
80#define PH_ASSERT_IN_RANGE_INCLUSIVE(value, lowerBound, upperBound)\
81 PH_ASSERT_MSG(lowerBound <= value && value <= upperBound, PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, "[", "]"))
85#define PH_ASSERT_IN_RANGE_EXCLUSIVE(value, lowerBound, upperBound)\
86 PH_ASSERT_MSG(lowerBound < value && value < upperBound, PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, "(", ")"))
97#define PH_STATIC_ASSERT_DEPENDENT_FALSE(DependentType, message)\
98 static_assert(::ph::detail::DEPENDENT_FALSE<DependentType>, #message)
Configurations for the entire toolset.
Useful macro definitions for general operations.
Implementation detail mainly for internal usages.
Definition assertion.h:9
void output_assertion_message(const std::string &filename, const std::string &lineNumber, const std::string &condition, const std::string &message)
Definition assertion.cpp:11
constexpr bool DEPENDENT_FALSE
Definition assertion.h:93
void on_assertion_failed()
Definition assertion.cpp:29