diff options
| author | Martin Hořeňovský | 2021-11-20 23:40:32 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-11-23 23:16:08 +0100 |
| commit | 8cb8f0b08b0ec35edd346df999f3b854ad05aa41 (patch) | |
| tree | f3482554c1eea8b3389d933a31137e41203b795a /src/catch2/internal | |
| parent | 9952f29f01ae1ab48b8c766ca70336bc3335f6e8 (diff) | |
| download | catch3-8cb8f0b08b0ec35edd346df999f3b854ad05aa41.tar.gz | |
Sweep out some Wsign-conversion warnings
Diffstat (limited to 'src/catch2/internal')
| -rw-r--r-- | src/catch2/internal/catch_sharding.hpp | 4 | ||||
| -rw-r--r-- | src/catch2/internal/catch_template_test_registry.hpp | 24 | ||||
| -rw-r--r-- | src/catch2/internal/catch_test_registry.cpp | 4 | ||||
| -rw-r--r-- | src/catch2/internal/catch_xmlwriter.cpp | 4 |
4 files changed, 19 insertions, 17 deletions
diff --git a/src/catch2/internal/catch_sharding.hpp b/src/catch2/internal/catch_sharding.hpp index 0e8822ee..17a206f8 100644 --- a/src/catch2/internal/catch_sharding.hpp +++ b/src/catch2/internal/catch_sharding.hpp @@ -30,8 +30,8 @@ namespace Catch { const std::size_t startIndex = shardIndex * shardSize + (std::min)(shardIndex, leftoverTests); const std::size_t endIndex = (shardIndex + 1) * shardSize + (std::min)(shardIndex + 1, leftoverTests); - auto startIterator = std::next(container.begin(), startIndex); - auto endIterator = std::next(container.begin(), endIndex); + auto startIterator = std::next(container.begin(), static_cast<std::ptrdiff_t>(startIndex)); + auto endIterator = std::next(container.begin(), static_cast<std::ptrdiff_t>(endIndex)); return Container(startIterator, endIterator); } diff --git a/src/catch2/internal/catch_template_test_registry.hpp b/src/catch2/internal/catch_template_test_registry.hpp index 235ee3e4..bfac3bc8 100644 --- a/src/catch2/internal/catch_template_test_registry.hpp +++ b/src/catch2/internal/catch_template_test_registry.hpp @@ -83,9 +83,9 @@ template<typename...Types> \ struct TestName{\ TestName(){\ - int index = 0; \ + size_t index = 0; \ constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\ - using expander = int[];\ + using expander = size_t[];\ (void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \ }\ };\ @@ -128,8 +128,8 @@ template<typename... Types> \ struct TestName { \ void reg_tests() { \ - int index = 0; \ - using expander = int[]; \ + size_t index = 0; \ + using expander = size_t[]; \ constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ @@ -176,8 +176,8 @@ template<typename... Types> \ struct TestName { \ void reg_tests() { \ - int index = 0; \ - using expander = int[]; \ + size_t index = 0; \ + using expander = size_t[]; \ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\ } \ };\ @@ -211,9 +211,9 @@ template<typename...Types> \ struct TestNameClass{\ TestNameClass(){\ - int index = 0; \ + size_t index = 0; \ constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\ - using expander = int[];\ + using expander = size_t[];\ (void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \ }\ };\ @@ -259,8 +259,8 @@ template<typename...Types>\ struct TestNameClass{\ void reg_tests(){\ - int index = 0;\ - using expander = int[];\ + std::size_t index = 0;\ + using expander = std::size_t[];\ constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ @@ -310,8 +310,8 @@ template<typename...Types>\ struct TestNameClass{\ void reg_tests(){\ - int index = 0;\ - using expander = int[];\ + size_t index = 0;\ + using expander = size_t[];\ (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */ \ }\ };\ diff --git a/src/catch2/internal/catch_test_registry.cpp b/src/catch2/internal/catch_test_registry.cpp index c9e9fe4f..faadb101 100644 --- a/src/catch2/internal/catch_test_registry.cpp +++ b/src/catch2/internal/catch_test_registry.cpp @@ -42,7 +42,9 @@ namespace Catch { auto const startIdx = reverseEnd - secondLastColons; auto const classNameSize = secondLastColons - lastColons - 1; - return methodName.substr( startIdx, classNameSize ); + return methodName.substr( + static_cast<std::size_t>( startIdx ), + static_cast<std::size_t>( classNameSize ) ); } } // namespace diff --git a/src/catch2/internal/catch_xmlwriter.cpp b/src/catch2/internal/catch_xmlwriter.cpp index 24af491a..93758cba 100644 --- a/src/catch2/internal/catch_xmlwriter.cpp +++ b/src/catch2/internal/catch_xmlwriter.cpp @@ -87,7 +87,7 @@ namespace { // (see: http://www.w3.org/TR/xml/#syntax) for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) { - unsigned char c = m_str[idx]; + unsigned char c = static_cast<unsigned char>(m_str[idx]); switch (c) { case '<': os << "<"; break; case '&': os << "&"; break; @@ -147,7 +147,7 @@ namespace { bool valid = true; uint32_t value = headerValue(c); for (std::size_t n = 1; n < encBytes; ++n) { - unsigned char nc = m_str[idx + n]; + unsigned char nc = static_cast<unsigned char>(m_str[idx + n]); valid &= ((nc & 0xC0) == 0x80); value = (value << 6) | (nc & 0x3F); } |