catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Exclude string-literal arrays from automatic range serialisation
- Commit
421ab160627d1490070f7310a10dae5b5616ded3- Author
- Phil Nash ·
- Parents
161dd4ed2449
Changes
include/internal/catch_tostring.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 5ca019fc..0bcf6bbb 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -136,6 +136,18 @@ namespace Catch { static std::string convert(wchar_t * str); }; + template<typename T> + struct is_string_array : std::false_type {}; + + template<std::size_t N> + struct is_string_array<char[N]> : std::true_type {}; + + template<std::size_t N> + struct is_string_array<signed char[N]> : std::true_type {}; + + template<std::size_t N> + struct is_string_array<unsigned char[N]> : std::true_type {}; + template<int SZ> struct StringMaker<char[SZ]> { static std::string convert(const char* str) { @@ -387,7 +399,7 @@ namespace Catch { } template<typename R> - struct StringMaker<R, typename std::enable_if<is_range<R>::value>::type> { + struct StringMaker<R, typename std::enable_if<is_range<R>::value && !is_string_array<R>::value>::type> { static std::string convert( R const& range ) { return rangeToString( range ); }