2020-08-30 15:43:45 +02:00
|
|
|
|
|
|
|
|
// Copyright Catch2 Authors
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
2022-10-28 11:22:53 +02:00
|
|
|
// (See accompanying file LICENSE.txt or copy at
|
2020-08-30 15:43:45 +02:00
|
|
|
// https://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2020-08-29 20:48:32 +02:00
|
|
|
#ifndef CATCH_ASSERTION_HANDLER_HPP_INCLUDED
|
|
|
|
|
#define CATCH_ASSERTION_HANDLER_HPP_INCLUDED
|
2017-08-08 17:53:01 +01:00
|
|
|
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/catch_assertion_info.hpp>
|
|
|
|
|
#include <catch2/internal/catch_decomposer.hpp>
|
|
|
|
|
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
2017-08-08 17:53:01 +01:00
|
|
|
|
2022-04-14 17:16:01 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
2017-08-08 17:53:01 +01:00
|
|
|
namespace Catch {
|
|
|
|
|
|
2017-11-27 22:21:47 +03:00
|
|
|
struct AssertionReaction {
|
|
|
|
|
bool shouldDebugBreak = false;
|
|
|
|
|
bool shouldThrow = false;
|
2023-01-12 15:01:47 +01:00
|
|
|
bool shouldSkip = false;
|
2017-11-27 22:21:47 +03:00
|
|
|
};
|
|
|
|
|
|
2017-08-08 17:53:01 +01:00
|
|
|
class AssertionHandler {
|
|
|
|
|
AssertionInfo m_assertionInfo;
|
2017-11-27 22:21:47 +03:00
|
|
|
AssertionReaction m_reaction;
|
2017-11-23 19:14:26 +00:00
|
|
|
bool m_completed = false;
|
2017-12-05 16:18:53 +00:00
|
|
|
IResultCapture& m_resultCapture;
|
2017-08-08 21:07:30 +01:00
|
|
|
|
2017-08-08 17:53:01 +01:00
|
|
|
public:
|
|
|
|
|
AssertionHandler
|
2021-05-14 23:45:59 +02:00
|
|
|
( StringRef macroName,
|
2017-08-08 17:53:01 +01:00
|
|
|
SourceLineInfo const& lineInfo,
|
|
|
|
|
StringRef capturedExpression,
|
|
|
|
|
ResultDisposition::Flags resultDisposition );
|
2017-12-09 20:17:47 +01:00
|
|
|
~AssertionHandler() {
|
|
|
|
|
if ( !m_completed ) {
|
2017-12-09 20:48:29 +01:00
|
|
|
m_resultCapture.handleIncomplete( m_assertionInfo );
|
2017-12-09 20:17:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-08 17:53:01 +01:00
|
|
|
|
|
|
|
|
template<typename T>
|
2017-11-24 19:15:46 +00:00
|
|
|
void handleExpr( ExprLhs<T> const& expr ) {
|
|
|
|
|
handleExpr( expr.makeUnaryExpr() );
|
2017-08-08 17:53:01 +01:00
|
|
|
}
|
2017-11-24 19:15:46 +00:00
|
|
|
void handleExpr( ITransientExpression const& expr );
|
|
|
|
|
|
2021-05-14 23:45:59 +02:00
|
|
|
void handleMessage(ResultWas::OfType resultType, StringRef message);
|
2017-08-08 17:53:01 +01:00
|
|
|
|
2017-11-24 19:15:46 +00:00
|
|
|
void handleExceptionThrownAsExpected();
|
|
|
|
|
void handleUnexpectedExceptionNotThrown();
|
|
|
|
|
void handleExceptionNotThrownAsExpected();
|
|
|
|
|
void handleThrowingCallSkipped();
|
|
|
|
|
void handleUnexpectedInflightException();
|
|
|
|
|
|
2017-11-23 19:14:26 +00:00
|
|
|
void complete();
|
2017-11-24 19:15:46 +00:00
|
|
|
|
|
|
|
|
// query
|
|
|
|
|
auto allowThrows() const -> bool;
|
2017-08-08 17:53:01 +01:00
|
|
|
};
|
|
|
|
|
|
2022-11-10 12:43:19 +01:00
|
|
|
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str );
|
2017-08-09 00:44:30 +01:00
|
|
|
|
2017-08-08 17:53:01 +01:00
|
|
|
} // namespace Catch
|
|
|
|
|
|
2020-08-29 20:48:32 +02:00
|
|
|
#endif // CATCH_ASSERTION_HANDLER_HPP_INCLUDED
|