mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-05 05:39:53 +01:00
Split out internal error macros from the common path
This commit is contained in:
parent
c815ad1d53
commit
feca97dfde
@ -132,6 +132,7 @@ set(INTERNAL_HEADERS
|
||||
${HEADER_DIR}/internal/catch_context.h
|
||||
${HEADER_DIR}/internal/catch_debugger.h
|
||||
${HEADER_DIR}/internal/catch_default_main.hpp
|
||||
${HEADER_DIR}/internal/catch_enforce.h
|
||||
${HEADER_DIR}/internal/catch_errno_guard.h
|
||||
${HEADER_DIR}/internal/catch_evaluate.hpp
|
||||
${HEADER_DIR}/internal/catch_exception_translator_registry.h
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "internal/catch_commandline.hpp"
|
||||
#include "internal/catch_console_colour.hpp"
|
||||
#include "internal/catch_enforce.h"
|
||||
#include "internal/catch_list.h"
|
||||
#include "internal/catch_run_context.hpp"
|
||||
#include "internal/catch_test_spec.hpp"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "catch_interfaces_config.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <ostream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
|
||||
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
|
||||
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -87,14 +88,6 @@ namespace Catch {
|
||||
|
||||
#define CATCH_INTERNAL_LINEINFO \
|
||||
::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
|
||||
#define CATCH_PREPARE_EXCEPTION( type, msg ) \
|
||||
type( static_cast<std::ostringstream&&>( std::ostringstream() << msg ).str() )
|
||||
#define CATCH_INTERNAL_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg);
|
||||
#define CATCH_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg )
|
||||
#define CATCH_ENFORCE( condition, msg ) \
|
||||
do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "catch_config.hpp"
|
||||
#include "catch_enforce.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "catch_console_colour.hpp"
|
||||
#include "catch_enforce.h"
|
||||
#include "catch_errno_guard.h"
|
||||
#include "catch_interfaces_config.h"
|
||||
#include "catch_stream.h"
|
||||
|
24
include/internal/catch_enforce.h
Normal file
24
include/internal/catch_enforce.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Created by Martin on 01/08/2017.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED
|
||||
|
||||
#include "catch_common.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
|
||||
#define CATCH_PREPARE_EXCEPTION( type, msg ) \
|
||||
type( static_cast<std::ostringstream&&>( std::ostringstream() << msg ).str() )
|
||||
#define CATCH_INTERNAL_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg);
|
||||
#define CATCH_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg )
|
||||
#define CATCH_ENFORCE( condition, msg ) \
|
||||
do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "catch_common.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Catch {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "catch_result_type.h"
|
||||
#include "catch_common.h"
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "catch_common.h"
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class NotImplementedException : public std::exception
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "catch_common.h"
|
||||
#include "catch_matchers.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct TestFailureException{};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "catch_run_context.hpp"
|
||||
#include "catch_enforce.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
|
||||
|
||||
#include "catch_common.h"
|
||||
#include "catch_enforce.h"
|
||||
#include "catch_stream.h"
|
||||
#include "catch_debugger.h"
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "catch_tag_alias_registry.h"
|
||||
#include "catch_console_colour.hpp"
|
||||
#include "catch_enforce.h"
|
||||
#include "catch_interfaces_registry_hub.h"
|
||||
#include "catch_stream.h"
|
||||
#include "catch_string_manip.h"
|
||||
|
@ -6,8 +6,9 @@
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include "catch_test_spec.hpp"
|
||||
#include "catch_test_case_info.h"
|
||||
#include "catch_enforce.h"
|
||||
#include "catch_test_spec.hpp"
|
||||
#include "catch_interfaces_testcase.h"
|
||||
#include "catch_string_manip.h"
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
|
||||
|
||||
#include "catch_common.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "catch_test_case_registry_impl.hpp"
|
||||
|
||||
#include "catch_context.h"
|
||||
#include "catch_enforce.h"
|
||||
#include "catch_interfaces_registry_hub.h"
|
||||
#include "catch_string_manip.h"
|
||||
#include "catch_test_case_info.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
#include <ios>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "catch_test_case_tracker.hpp"
|
||||
|
||||
#include "catch_enforce.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <stdexcept>
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "catch_wildcard_pattern.hpp"
|
||||
#include "catch_enforce.h"
|
||||
#include "catch_string_manip.h"
|
||||
|
||||
|
||||
|
@ -8,8 +8,10 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
||||
|
||||
#include "../internal/catch_enforce.h"
|
||||
#include "../internal/catch_interfaces_reporter.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <cfloat>
|
||||
|
Loading…
Reference in New Issue
Block a user