mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Merge pull request #2138 from catchorg/devel-config-splitting
Split some configuration options out of catch_compiler_capabilities
This commit is contained in:
commit
f5b413aa58
@ -52,7 +52,9 @@ set(INTERNAL_HEADERS
|
|||||||
${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp
|
${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp
|
||||||
${SOURCES_DIR}/catch_config.hpp
|
${SOURCES_DIR}/catch_config.hpp
|
||||||
${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp
|
${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp
|
||||||
|
${SOURCES_DIR}/internal/catch_config_counter.hpp
|
||||||
${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
|
${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
|
||||||
|
${SOURCES_DIR}/internal/catch_config_wchar.hpp
|
||||||
${SOURCES_DIR}/internal/catch_console_colour.hpp
|
${SOURCES_DIR}/internal/catch_console_colour.hpp
|
||||||
${SOURCES_DIR}/internal/catch_context.hpp
|
${SOURCES_DIR}/internal/catch_context.hpp
|
||||||
${SOURCES_DIR}/internal/catch_debug_console.hpp
|
${SOURCES_DIR}/internal/catch_debug_console.hpp
|
||||||
|
@ -51,7 +51,9 @@
|
|||||||
#include <catch2/internal/catch_commandline.hpp>
|
#include <catch2/internal/catch_commandline.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
#include <catch2/internal/catch_config_android_logwrite.hpp>
|
#include <catch2/internal/catch_config_android_logwrite.hpp>
|
||||||
|
#include <catch2/internal/catch_config_counter.hpp>
|
||||||
#include <catch2/internal/catch_config_uncaught_exceptions.hpp>
|
#include <catch2/internal/catch_config_uncaught_exceptions.hpp>
|
||||||
|
#include <catch2/internal/catch_config_wchar.hpp>
|
||||||
#include <catch2/internal/catch_console_colour.hpp>
|
#include <catch2/internal/catch_console_colour.hpp>
|
||||||
#include <catch2/internal/catch_console_width.hpp>
|
#include <catch2/internal/catch_console_width.hpp>
|
||||||
#include <catch2/internal/catch_container_nonmembers.hpp>
|
#include <catch2/internal/catch_container_nonmembers.hpp>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <catch2/internal/catch_noncopyable.hpp>
|
#include <catch2/internal/catch_noncopyable.hpp>
|
||||||
#include <catch2/catch_config.hpp>
|
#include <catch2/catch_config.hpp>
|
||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_config_wchar.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#ifndef CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
|
#ifndef CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
|
||||||
#define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
|
#define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
#include <catch2/internal/catch_source_line_info.hpp>
|
#include <catch2/internal/catch_source_line_info.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
|
#include <catch2/internal/catch_config_wchar.hpp>
|
||||||
#include <catch2/internal/catch_stream.hpp>
|
#include <catch2/internal/catch_stream.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
|
#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
|
||||||
|
|
||||||
@ -162,7 +163,7 @@ namespace Catch {
|
|||||||
static std::string convert(char * str);
|
static std::string convert(char * str);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_WCHAR
|
#if defined(CATCH_CONFIG_WCHAR)
|
||||||
template<>
|
template<>
|
||||||
struct StringMaker<std::wstring> {
|
struct StringMaker<std::wstring> {
|
||||||
static std::string convert(const std::wstring& wstr);
|
static std::string convert(const std::wstring& wstr);
|
||||||
@ -183,7 +184,7 @@ namespace Catch {
|
|||||||
struct StringMaker<wchar_t *> {
|
struct StringMaker<wchar_t *> {
|
||||||
static std::string convert(wchar_t * str);
|
static std::string convert(wchar_t * str);
|
||||||
};
|
};
|
||||||
#endif
|
#endif // CATCH_CONFIG_WCHAR
|
||||||
|
|
||||||
// TBD: Should we use `strnlen` to ensure that we don't go out of the buffer,
|
// TBD: Should we use `strnlen` to ensure that we don't go out of the buffer,
|
||||||
// while keeping string semantics?
|
// while keeping string semantics?
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
// Detect a number of compiler features - by compiler
|
// Detect a number of compiler features - by compiler
|
||||||
// The following features are defined:
|
// The following features are defined:
|
||||||
//
|
//
|
||||||
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
|
|
||||||
// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?
|
// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?
|
||||||
// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported?
|
// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported?
|
||||||
// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled?
|
// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled?
|
||||||
@ -186,11 +185,6 @@
|
|||||||
# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED
|
# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// DJGPP
|
|
||||||
#ifdef __DJGPP__
|
|
||||||
# define CATCH_INTERNAL_CONFIG_NO_WCHAR
|
|
||||||
#endif // __DJGPP__
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Embarcadero C++Build
|
// Embarcadero C++Build
|
||||||
@ -198,18 +192,6 @@
|
|||||||
#define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN
|
#define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Use of __COUNTER__ is suppressed during code analysis in
|
|
||||||
// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly
|
|
||||||
// handled by it.
|
|
||||||
// Otherwise all supported compilers support COUNTER macro,
|
|
||||||
// but user still might want to turn it off
|
|
||||||
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
|
|
||||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// RTX is a special version of Windows that is real time.
|
// RTX is a special version of Windows that is real time.
|
||||||
@ -263,9 +245,6 @@
|
|||||||
#endif // defined(__has_include)
|
#endif // defined(__has_include)
|
||||||
|
|
||||||
|
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
|
||||||
# define CATCH_CONFIG_COUNTER
|
|
||||||
#endif
|
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)
|
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)
|
||||||
# define CATCH_CONFIG_WINDOWS_SEH
|
# define CATCH_CONFIG_WINDOWS_SEH
|
||||||
#endif
|
#endif
|
||||||
@ -273,10 +252,6 @@
|
|||||||
#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
|
#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
|
||||||
# define CATCH_CONFIG_POSIX_SIGNALS
|
# define CATCH_CONFIG_POSIX_SIGNALS
|
||||||
#endif
|
#endif
|
||||||
// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions.
|
|
||||||
#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR)
|
|
||||||
# define CATCH_CONFIG_WCHAR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING)
|
#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING)
|
||||||
# define CATCH_CONFIG_CPP11_TO_STRING
|
# define CATCH_CONFIG_CPP11_TO_STRING
|
||||||
|
32
src/catch2/internal/catch_config_counter.hpp
Normal file
32
src/catch2/internal/catch_config_counter.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
// Copyright Catch2 Authors
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* Wrapper for the CONFIG configuration option
|
||||||
|
*
|
||||||
|
* When generating internal unique names, there are two options. Either
|
||||||
|
* we mix in the current line number, or mix in an incrementing number.
|
||||||
|
* We prefer the latter, using `__COUNTER__`, but users might want to
|
||||||
|
* use the former.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED
|
||||||
|
#define CATCH_CONFIG_COUNTER_HPP_INCLUDED
|
||||||
|
|
||||||
|
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
|
||||||
|
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \
|
||||||
|
!defined( CATCH_CONFIG_NO_COUNTER ) && \
|
||||||
|
!defined( CATCH_CONFIG_COUNTER )
|
||||||
|
# define CATCH_CONFIG_COUNTER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED
|
33
src/catch2/internal/catch_config_wchar.hpp
Normal file
33
src/catch2/internal/catch_config_wchar.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
// Copyright Catch2 Authors
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* Wrapper for the WCHAR configuration option
|
||||||
|
*
|
||||||
|
* We want to support platforms that do not provide `wchar_t`, so we
|
||||||
|
* sometimes have to disable providing wchar_t overloads through Catch2,
|
||||||
|
* e.g. the StringMaker specialization for `std::wstring`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED
|
||||||
|
#define CATCH_CONFIG_WCHAR_HPP_INCLUDED
|
||||||
|
|
||||||
|
// We assume that WCHAR should be enabled by default, and only disabled
|
||||||
|
// for a shortlist (so far only DJGPP) of compilers.
|
||||||
|
|
||||||
|
#if defined(__DJGPP__)
|
||||||
|
# define CATCH_INTERNAL_CONFIG_NO_WCHAR
|
||||||
|
#endif // __DJGPP__
|
||||||
|
|
||||||
|
#if !defined( CATCH_INTERNAL_CONFIG_NO_WCHAR ) && \
|
||||||
|
!defined( CATCH_CONFIG_NO_WCHAR ) && \
|
||||||
|
!defined( CATCH_CONFIG_WCHAR )
|
||||||
|
# define CATCH_CONFIG_WCHAR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CATCH_CONFIG_WCHAR_HPP_INCLUDED
|
@ -7,6 +7,7 @@
|
|||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
#include <catch2/catch_session.hpp>
|
#include <catch2/catch_session.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
|
#include <catch2/internal/catch_config_wchar.hpp>
|
||||||
#include <catch2/internal/catch_leak_detector.hpp>
|
#include <catch2/internal/catch_leak_detector.hpp>
|
||||||
#include <catch2/internal/catch_platform.hpp>
|
#include <catch2/internal/catch_platform.hpp>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
|
#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
|
||||||
#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
|
#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_config_counter.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#ifndef CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
#ifndef CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||||
#define CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
#define CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
|
||||||
#include <catch2/internal/catch_source_line_info.hpp>
|
#include <catch2/internal/catch_source_line_info.hpp>
|
||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include <catch2/internal/catch_source_line_info.hpp>
|
#include <catch2/internal/catch_source_line_info.hpp>
|
||||||
#include <catch2/internal/catch_noncopyable.hpp>
|
#include <catch2/internal/catch_noncopyable.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
|
||||||
#include <catch2/internal/catch_stringref.hpp>
|
#include <catch2/internal/catch_stringref.hpp>
|
||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#define CATCH_XMLWRITER_HPP_INCLUDED
|
#define CATCH_XMLWRITER_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/internal/catch_stream.hpp>
|
#include <catch2/internal/catch_stream.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
|
||||||
|
|
||||||
// FixMe: Without this include (and something inside it), MSVC goes crazy
|
// FixMe: Without this include (and something inside it), MSVC goes crazy
|
||||||
// and reports that calls to XmlEncode's op << are ambiguous between
|
// and reports that calls to XmlEncode's op << are ambiguous between
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_platform.hpp>
|
||||||
#include <catch2/internal/catch_console_colour.hpp>
|
#include <catch2/internal/catch_console_colour.hpp>
|
||||||
#include <catch2/internal/catch_string_manip.hpp>
|
#include <catch2/internal/catch_string_manip.hpp>
|
||||||
#include <catch2/internal/catch_stringref.hpp>
|
#include <catch2/internal/catch_stringref.hpp>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <catch2/catch_template_test_macros.hpp>
|
#include <catch2/catch_template_test_macros.hpp>
|
||||||
|
#include <catch2/internal/catch_config_wchar.hpp>
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||||
@ -423,7 +424,7 @@ TEST_CASE( "Tabs and newlines show in output", "[.][whitespace][failing]" ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_WCHAR
|
#if defined(CATCH_CONFIG_WCHAR)
|
||||||
TEST_CASE( "toString on const wchar_t const pointer returns the string contents", "[toString]" ) {
|
TEST_CASE( "toString on const wchar_t const pointer returns the string contents", "[toString]" ) {
|
||||||
const wchar_t * const s = L"wide load";
|
const wchar_t * const s = L"wide load";
|
||||||
std::string result = ::Catch::Detail::stringify( s );
|
std::string result = ::Catch::Detail::stringify( s );
|
||||||
@ -447,7 +448,7 @@ TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
|
|||||||
std::string result = ::Catch::Detail::stringify( s );
|
std::string result = ::Catch::Detail::stringify( s );
|
||||||
CHECK( result == "\"wide load\"" );
|
CHECK( result == "\"wide load\"" );
|
||||||
}
|
}
|
||||||
#endif
|
#endif // CATCH_CONFIG_WCHAR
|
||||||
|
|
||||||
TEST_CASE( "long long" ) {
|
TEST_CASE( "long long" ) {
|
||||||
long long l = std::numeric_limits<long long>::max();
|
long long l = std::numeric_limits<long long>::max();
|
||||||
|
Loading…
Reference in New Issue
Block a user