24class AssertionDispatcher
27 explicit AssertionDispatcher (Assertion assertion) :
28 m_assertion (std::move (assertion))
30 if (! m_assertion.hasFailed())
34 << m_assertion.getFile() <<
':' << m_assertion.getLine() <<
'\n'
35 << (m_assertion.getLevel() == Assertion::Level::expect ?
"HART_EXPECT()" :
"HART_ASSERT()")
36 <<
" failed: \nCondition: ";
37 m_assertion.representWithTokens (m_messageStream);
38 m_messageStream <<
"\nEvaluated: ";
39 m_assertion.representWithStringRepresentations (m_messageStream);
42 AssertionDispatcher (
const AssertionDispatcher&) =
delete;
43 AssertionDispatcher (AssertionDispatcher&&) =
delete;
44 AssertionDispatcher& operator= (
const AssertionDispatcher&) =
delete;
45 AssertionDispatcher& operator= (AssertionDispatcher&&) =
delete;
47 template <
typename Type>
48 AssertionDispatcher& operator<< (
const Type& value)
50 if (m_assertion.hasFailed())
54 m_hasUserLabel =
true;
55 m_messageStream <<
"\nLabel: \"";
58 m_messageStream << value;
64 ~AssertionDispatcher()
noexcept(
false)
66 if (! m_assertion.hasFailed())
70 m_messageStream <<
'\"';
72 const std::string message = m_messageStream.str();
77 ExpectationFailureMessages::get().emplace_back (message);
81 const Assertion m_assertion;
82 bool m_hasUserLabel =
false;
83 std::ostringstream m_messageStream;
Thrown by test asserts like HART_ASSERT_TRUE() and AudioTestBuilder::assertFalse()
static bool isExceptionUnwinding()
Returns true if an exception is currently being unwound.