Compare commits

...

18 Commits

Author SHA1 Message Date
Martin Hořeňovský
ee1450f268 Merge pull request #2862 from rikyoz/backport-clang-tidy-bugprone-chained-comparison
Fix clang-tidy `bugprone-chained-comparison` warnings on v2.x
2024-04-25 14:29:32 +02:00
Oz
a2b2e1f707 Fix clang-tidy bugprone-chained-comparison warnings on v2.x 2024-04-22 22:05:38 +02:00
morinmorin
a7782d1d7c Add workaround for unguarded use of __has_extension (for v2.x) 2024-03-12 22:58:19 +01:00
Martin Hořeňovský
d4b0b34561 Fix lowercase namespace in own-main example
Fixes #2715
2023-07-13 14:02:19 +02:00
Martin Sternevald
c359076e8a Fix missing include causing compiler error
catch_registry_hub.cpp:65:17: error: use of undeclared identifier 'CATCH_INTERNAL_ERROR'
                CATCH_INTERNAL_ERROR("Attempted to register active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!");
2022-12-10 23:35:59 +01:00
alvinhochun
20ace55034 Allow ANSI colour to be compiled on Windows
This enables building with `CATCH_CONFIG_COLOUR_ANSI` on Windows. The changes are taken from v3 commit 0e176c318b.
2022-10-25 12:10:28 +02:00
Martin Hořeňovský
182c910b4b v2.13.10 2022-10-16 11:02:17 +02:00
Thomas Gamper
02123776f2 fixes catchorg/Catch2#2401 2022-08-21 19:51:36 +02:00
David Matson
14bc25be00 Explicitly specify __cdecl on main/wmain for MSVC (#2487)
Fixes #2486

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2022-08-06 21:15:53 +02:00
Martin Hořeňovský
20d413b8b6 Fix comma-subscript warning suppression to only target GCC 10.1+
Fixes #2416
2022-06-06 01:04:12 +02:00
Martin Hořeňovský
e33de8fc05 Update FetchContent docs to use 2.13.9 2022-05-31 12:31:02 +02:00
Martin Hořeňovský
1127d847a1 Use better instruction for CATCH_TRAP on ARM Macs
The old instruction would cause the debugger to be stuck at the
triggering source line forever, while the new one should have the
expected semantics, where the debugger can then single-step,
continue. or generally do things, afterwards.

Closes #2422
2022-05-15 23:20:32 +02:00
Marc Mutz
ca455815fd ObjectStorage: port away from std::aligned_storage
It's deprecated in C++23. Just use alignas on a char array, wrapped in
a struct to avoid decaying to char*, which is the canonical
implementation of aligned_storage:
https://en.cppreference.com/w/cpp/types/aligned_storage#Possible_implementation

Fixes #2419

Catch3 is not affected.
2022-05-10 00:06:45 +02:00
Martin Hořeňovský
d71b4617e9 Disable Werror for unknown pragmas in tests
Closes #2375
2022-04-17 21:12:38 +02:00
Martin Hořeňovský
62fd660583 v2.13.9 2022-04-12 22:38:17 +02:00
Martin Mekota
0aa4dbae2e Fix filename as tag bug
When a test file isn't provided with "/" in the path,
the filename isn't registered as a tag.
Fixing by providing a conditon for this edge case.

Closes #2328
2022-03-18 22:32:54 +01:00
John Beard
ff151d2833 Fix: CAPTURE not variadic when disabled (#2378)
Closes: #2316
2022-03-04 15:29:22 +01:00
Mikhail Matrosov
958944d27a Allow to specify CATCH_CONFIG_DEFAULT_REPORTER for static library with main() (#2346) 2022-01-25 21:54:19 +01:00
20 changed files with 94 additions and 37 deletions

View File

@@ -16,7 +16,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
project(Catch2 LANGUAGES CXX VERSION 2.13.8)
project(Catch2 LANGUAGES CXX VERSION 2.13.10)
# Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
@@ -116,6 +116,10 @@ if (CATCH_BUILD_STATIC_LIBRARY)
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 10))
target_compile_options(Catch2WithMain PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
endif()
if (CATCH_CONFIG_DEFAULT_REPORTER)
target_compile_definitions(Catch2WithMain PRIVATE CATCH_CONFIG_DEFAULT_REPORTER=${CATCH_CONFIG_DEFAULT_REPORTER})
endif()
endif(CATCH_BUILD_STATIC_LIBRARY)
# Only perform the installation steps when Catch is not being used as

View File

@@ -9,7 +9,7 @@
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)
<a href="https://github.com/catchorg/Catch2/releases/download/v2.13.8/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
<a href="https://github.com/catchorg/Catch2/releases/download/v2.13.10/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released!

View File

@@ -43,7 +43,8 @@ Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.1)
GIT_TAG v2.13.9 # or a later release
)
FetchContent_MakeAvailable(Catch2)

View File

@@ -87,7 +87,7 @@ int main( int argc, char* argv[] )
int height = 0; // Some user variable you want to be able to set
// Build a new parser on top of Catch's
using namespace Catch::clara;
using namespace Catch::Clara;
auto cli
= session.cli() // Get Catch's composite command line parser
| Opt( height, "height" ) // bind variable to a new option, with a hint string

View File

@@ -2,6 +2,8 @@
# Release notes
**Contents**<br>
[2.13.10](#21310)<br>
[2.13.9](#2139)<br>
[2.13.8](#2138)<br>
[2.13.7](#2137)<br>
[2.13.6](#2136)<br>
@@ -49,6 +51,22 @@
[Even Older versions](#even-older-versions)<br>
## 2.13.10
### Fixes
* Fixed issue with `catch_discover_tests` when there is multiple of 256 tests (#2401, #2503)
* Catch2-provided `main` and `wmain` are explicitly marked as `__cdecl` when compiled with MSVC (#2486, #2487)
* Improved break-into-debugger behaviour for ARM Macs. It should now be possible to step execution after the break (#2422)
* Replaced deprecated `std::aligned_storage` (#2419, #2420)
## 2.13.9
### Fixes
* Fixed issue with `-#` (filename-as-tag) flag when `__FILE__` expands into filename without directories (#2328, #2393)
* Fixed `CAPTURE` macro not being variadic when disabled through `CATCH_CONFIG_DISABLE` (#2316, #2378)
## 2.13.8
### Fixes

View File

@@ -11,7 +11,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 8
#define CATCH_VERSION_PATCH 10
#ifdef __clang__
# pragma clang system_header
@@ -433,7 +433,7 @@ using Catch::Detail::Approx;
#define INFO( msg ) (void)(0)
#define UNSCOPED_INFO( msg ) (void)(0)
#define WARN( msg ) (void)(0)
#define CAPTURE( msg ) (void)(0)
#define CAPTURE( ... ) (void)(0)
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ))
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ))

View File

@@ -19,8 +19,6 @@ namespace Catch {
template <typename T, bool Destruct>
struct ObjectStorage
{
using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
ObjectStorage() : data() {}
ObjectStorage(const ObjectStorage& other)
@@ -64,7 +62,7 @@ namespace Catch {
}
TStorage data;
struct { alignas(T) unsigned char data[sizeof(T)]; } data;
};
}

View File

@@ -47,7 +47,7 @@
INTERNAL_CATCH_TRY { \
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); /* NOLINT(bugprone-chained-comparison) */ \
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
INTERNAL_CATCH_REACT( catchAssertionHandler ) \

View File

@@ -121,7 +121,10 @@ namespace {
#elif defined( CATCH_CONFIG_COLOUR_ANSI ) //////////////////////////////////////
#include <unistd.h>
#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC )
# define CATCH_INTERNAL_HAS_ISATTY
# include <unistd.h>
#endif
namespace Catch {
namespace {
@@ -170,7 +173,8 @@ namespace {
#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE)
!isDebuggerActive() &&
#endif
#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__))
#if defined( CATCH_INTERNAL_HAS_ISATTY ) && \
!( defined( __DJGPP__ ) && defined( __STRICT_ANSI__ ) )
isatty(STDOUT_FILENO)
#else
false

View File

@@ -20,7 +20,7 @@ namespace Catch {
#if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
#define CATCH_TRAP() __asm__(".inst 0xd4200000")
#define CATCH_TRAP() __asm__(".inst 0xd43e0000")
#endif
#elif defined(CATCH_PLATFORM_IPHONE)

View File

@@ -13,12 +13,20 @@
#ifndef __OBJC__
#ifndef CATCH_INTERNAL_CDECL
#ifdef _MSC_VER
#define CATCH_INTERNAL_CDECL __cdecl
#else
#define CATCH_INTERNAL_CDECL
#endif
#endif
#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
// Standard C/C++ Win32 Unicode wmain entry point
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point
int main (int argc, char * argv[]) {
int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) {
#endif
return Catch::Session().run( argc, argv );

View File

@@ -12,6 +12,9 @@
// See e.g.:
// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html
#ifdef __APPLE__
# ifndef __has_extension
# define __has_extension(x) 0
# endif
# include <TargetConditionals.h>
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \
(defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)

View File

@@ -9,6 +9,7 @@
#include "catch_interfaces_registry_hub.h"
#include "catch_context.h"
#include "catch_enforce.h"
#include "catch_test_case_registry_impl.h"
#include "catch_reporter_registry.h"
#include "catch_exception_translator_registry.h"

View File

@@ -127,6 +127,10 @@ namespace Catch {
filename.erase(0, lastSlash);
filename[0] = '#';
}
else
{
filename.insert(0, "#");
}
auto lastDot = filename.find_last_of('.');
if (lastDot != std::string::npos) {
@@ -289,7 +293,7 @@ namespace Catch {
// Handle list request
if( Option<std::size_t> listed = list( m_config ) )
return static_cast<int>( *listed );
return (std::min) (MaxExitCode, static_cast<int>(*listed));
TestGroup tests { m_config };
auto const totals = tests.execute();

View File

@@ -37,7 +37,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 13, 8, "", 0 );
static Version version( 2, 13, 10, "", 0 );
return version;
}

View File

@@ -354,7 +354,7 @@ endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code -Wpedantic -Wmissing-declarations )
if (CATCH_ENABLE_WERROR)
target_compile_options( SelfTest PRIVATE -Werror )
target_compile_options( SelfTest PRIVATE -Werror -Wno-error=pragmas )
endif()
endif()
# Clang specific options go here

View File

@@ -53,6 +53,7 @@ CATCH_TEST_CASE("PrefixedMacros") {
CATCH_SECTION("some section") {
int i = 1;
CATCH_CAPTURE( i );
CATCH_CAPTURE( i, i + 1 );
CATCH_DYNAMIC_SECTION("Dynamic section: " << i) {
CATCH_FAIL_CHECK( "failure" );
}

View File

@@ -26,6 +26,10 @@ foo f;
// This test should not be run, because it won't be registered
TEST_CASE( "Disabled Macros" ) {
CAPTURE( 1 );
CAPTURE( 1, "captured" );
std::cout << "This should not happen\n";
FAIL();
}

View File

@@ -241,17 +241,19 @@ std::ostream& operator<<(std::ostream& out, helper_1436<T1, T2> const& helper) {
return out;
}
// clang can handle GCC's diagnostic pragma
#if defined( __GNUG__ ) || defined(__clang__)
# pragma GCC diagnostic push
#endif
// Clang and gcc have different names for this warning, and clang also
// warns about an unused value
#if defined(__GNUG__) && !defined(__clang__)
#pragma GCC diagnostic push
#if defined( __GNUG__ ) && !defined( __clang__ ) && \
( __GNUG__ > 10 || ( __GNUG__ == 10 && __GNUC_MINOR__ >= 1 ) )
#pragma GCC diagnostic ignored "-Wcomma-subscript"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-comma-subscript"
#pragma clang diagnostic ignored "-Wunused-value"
#endif
TEST_CASE("CAPTURE can deal with complex expressions involving commas", "[messages][capture]") {
CAPTURE(std::vector<int>{1, 2, 3}[0, 1, 2],
std::vector<int>{1, 2, 3}[(0, 1)],
@@ -261,9 +263,8 @@ TEST_CASE("CAPTURE can deal with complex expressions involving commas", "[messag
CAPTURE( (1, 2), (2, 3) );
SUCCEED();
}
#ifdef __GNUG__
#pragma GCC diagnostic pop
#if defined( __GNUG__ ) || defined(__clang__)
# pragma GCC diagnostic pop
#endif
TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]") {

View File

@@ -1,6 +1,6 @@
/*
* Catch v2.13.8
* Generated: 2022-01-03 21:20:09.589503
* Catch v2.13.10
* Generated: 2022-10-16 11:01:23.452308
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved.
@@ -15,7 +15,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 8
#define CATCH_VERSION_PATCH 10
#ifdef __clang__
# pragma clang system_header
@@ -7395,8 +7395,6 @@ namespace Catch {
template <typename T, bool Destruct>
struct ObjectStorage
{
using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
ObjectStorage() : data() {}
ObjectStorage(const ObjectStorage& other)
@@ -7439,7 +7437,7 @@ namespace Catch {
return *static_cast<T*>(static_cast<void*>(&data));
}
TStorage data;
struct { alignas(T) unsigned char data[sizeof(T)]; } data;
};
}
@@ -7949,7 +7947,7 @@ namespace Catch {
#if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
#define CATCH_TRAP() __asm__(".inst 0xd4200000")
#define CATCH_TRAP() __asm__(".inst 0xd43e0000")
#endif
#elif defined(CATCH_PLATFORM_IPHONE)
@@ -13392,6 +13390,10 @@ namespace Catch {
filename.erase(0, lastSlash);
filename[0] = '#';
}
else
{
filename.insert(0, "#");
}
auto lastDot = filename.find_last_of('.');
if (lastDot != std::string::npos) {
@@ -13554,7 +13556,7 @@ namespace Catch {
// Handle list request
if( Option<std::size_t> listed = list( m_config ) )
return static_cast<int>( *listed );
return (std::min) (MaxExitCode, static_cast<int>(*listed));
TestGroup tests { m_config };
auto const totals = tests.execute();
@@ -15387,7 +15389,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 13, 8, "", 0 );
static Version version( 2, 13, 10, "", 0 );
return version;
}
@@ -17522,12 +17524,20 @@ namespace Catch {
#ifndef __OBJC__
#ifndef CATCH_INTERNAL_CDECL
#ifdef _MSC_VER
#define CATCH_INTERNAL_CDECL __cdecl
#else
#define CATCH_INTERNAL_CDECL
#endif
#endif
#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
// Standard C/C++ Win32 Unicode wmain entry point
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point
int main (int argc, char * argv[]) {
int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) {
#endif
return Catch::Session().run( argc, argv );
@@ -17890,7 +17900,7 @@ using Catch::Detail::Approx;
#define INFO( msg ) (void)(0)
#define UNSCOPED_INFO( msg ) (void)(0)
#define WARN( msg ) (void)(0)
#define CAPTURE( msg ) (void)(0)
#define CAPTURE( ... ) (void)(0)
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ))
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ))