Compare commits

...

8 Commits

Author SHA1 Message Date
Martin Hořeňovský 9712bc8fe5 Merge pull request #3184 from ZheFeng7110/fix/v2.x-user_literal-warn
(v2.x) Remove space in user-defined literal operators to fix MSVC C4996 warning
2026-07-28 11:53:18 +02:00
Zhe Feng c002f18535 Fix MSVC deprecation warning for user-defined literals
Remove the space between "" and the suffix in user-defined literal
operators (e.g. operator ""_a instead of operator "" _a) to avoid
MSVC deprecation warning C5311.
2026-07-27 20:08:43 +08:00
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
10 changed files with 25 additions and 17 deletions
+1 -1
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
+2 -2
View File
@@ -73,10 +73,10 @@ namespace Detail {
} // end namespace Detail
namespace literals {
Detail::Approx operator "" _a(long double val) {
Detail::Approx operator ""_a(long double val) {
return Detail::Approx(val);
}
Detail::Approx operator "" _a(unsigned long long val) {
Detail::Approx operator ""_a(unsigned long long val) {
return Detail::Approx(val);
}
} // end namespace literals
+2 -2
View File
@@ -118,8 +118,8 @@ namespace Detail {
} // end namespace Detail
namespace literals {
Detail::Approx operator "" _a(long double val);
Detail::Approx operator "" _a(unsigned long long val);
Detail::Approx operator ""_a(long double val);
Detail::Approx operator ""_a(unsigned long long val);
} // end namespace literals
template<>
+1 -1
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 ) \
+6 -2
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
+3
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)
+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"
+2 -2
View File
@@ -92,12 +92,12 @@ namespace Catch {
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
return StringRef( rawChars, size );
}
} // namespace Catch
constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
return Catch::StringRef( rawChars, size );
}
@@ -141,7 +141,7 @@ TEST_CASE("StringRef at compilation time", "[Strings][StringRef][constexpr]") {
STATIC_REQUIRE(sr1.size() == 3);
STATIC_REQUIRE(sr1.isNullTerminated());
using Catch::operator"" _sr;
using Catch::operator""_sr;
constexpr auto sr2 = ""_sr;
STATIC_REQUIRE(sr2.empty());
STATIC_REQUIRE(sr2.size() == 0);
+6 -6
View File
@@ -677,12 +677,12 @@ namespace Catch {
auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&;
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
return StringRef( rawChars, size );
}
} // namespace Catch
constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
return Catch::StringRef( rawChars, size );
}
@@ -3177,8 +3177,8 @@ namespace Detail {
} // end namespace Detail
namespace literals {
Detail::Approx operator "" _a(long double val);
Detail::Approx operator "" _a(unsigned long long val);
Detail::Approx operator ""_a(long double val);
Detail::Approx operator ""_a(unsigned long long val);
} // end namespace literals
template<>
@@ -7920,10 +7920,10 @@ namespace Detail {
} // end namespace Detail
namespace literals {
Detail::Approx operator "" _a(long double val) {
Detail::Approx operator ""_a(long double val) {
return Detail::Approx(val);
}
Detail::Approx operator "" _a(unsigned long long val) {
Detail::Approx operator ""_a(unsigned long long val) {
return Detail::Approx(val);
}
} // end namespace literals