Split out internal error macros from the common path

This commit is contained in:
Martin Hořeňovský 2017-08-01 18:46:33 +02:00
parent c815ad1d53
commit feca97dfde
21 changed files with 52 additions and 12 deletions

View File

@ -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

View File

@ -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"

View File

@ -11,6 +11,7 @@
#include "catch_interfaces_config.h"
#include <cstring>
#include <ostream>
namespace Catch {

View File

@ -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

View File

@ -6,6 +6,7 @@
*/
#include "catch_config.hpp"
#include "catch_enforce.h"
namespace Catch {

View File

@ -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"

View 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

View File

@ -12,6 +12,7 @@
#include "catch_common.h"
#include <string>
#include <vector>
namespace Catch {

View File

@ -9,6 +9,7 @@
#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED
#include <string>
#include <sstream>
#include "catch_result_type.h"
#include "catch_common.h"

View File

@ -10,6 +10,8 @@
#include "catch_common.h"
#include <exception>
namespace Catch {
class NotImplementedException : public std::exception

View File

@ -13,6 +13,8 @@
#include "catch_common.h"
#include "catch_matchers.hpp"
#include <sstream>
namespace Catch {
struct TestFailureException{};

View File

@ -1,4 +1,5 @@
#include "catch_run_context.hpp"
#include "catch_enforce.h"
#include <cassert>
#include <algorithm>

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -15,7 +15,7 @@
#include <vector>
#include <set>
#include <algorithm>
#include <ios>
namespace Catch {

View File

@ -7,6 +7,8 @@
#include "catch_test_case_tracker.hpp"
#include "catch_enforce.h"
#include <algorithm>
#include <assert.h>
#include <stdexcept>

View File

@ -6,6 +6,7 @@
*/
#include "catch_wildcard_pattern.hpp"
#include "catch_enforce.h"
#include "catch_string_manip.h"

View File

@ -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>