Use constexpr StringRef instance for unprintable strings

This commit is contained in:
Martin Hořeňovský 2021-05-15 12:02:02 +02:00
parent 8ee422d6bf
commit 4cc247cc70
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
2 changed files with 2 additions and 15 deletions

View File

@ -5,12 +5,6 @@
// https://www.boost.org/LICENSE_1_0.txt) // https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wexit-time-destructors"
# pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
#include <catch2/catch_tostring.hpp> #include <catch2/catch_tostring.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp> #include <catch2/interfaces/catch_interfaces_config.hpp>
@ -24,8 +18,6 @@ namespace Catch {
namespace Detail { namespace Detail {
const std::string unprintableString = "{?}";
namespace { namespace {
const int hexThreshold = 255; const int hexThreshold = 255;
@ -237,8 +229,3 @@ std::string StringMaker<double>::convert(double value) {
} }
} // end namespace Catch } // end namespace Catch
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

View File

@ -30,7 +30,7 @@
namespace Catch { namespace Catch {
namespace Detail { namespace Detail {
extern const std::string unprintableString; constexpr StringRef unprintableString = "{?}"_sr;
std::string rawMemoryToString( const void *object, std::size_t size ); std::string rawMemoryToString( const void *object, std::size_t size );
@ -59,7 +59,7 @@ namespace Catch {
std::enable_if_t< std::enable_if_t<
!std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value, !std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value,
std::string> convertUnstreamable( T const& ) { std::string> convertUnstreamable( T const& ) {
return Detail::unprintableString; return std::string(Detail::unprintableString);
} }
template<typename T> template<typename T>
std::enable_if_t< std::enable_if_t<