Progmasoft Git

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

Misc cleanups from exploring Clang warnings

Commit
198808a24e252bf049df24c2f3d4b4d69c892a39
Author
Martin Hořeňovský ·
Parents
198713e5dc2c

Files · Download .tar.gz

Changes

 src/catch2/benchmark/catch_constructor.hpp                 | 4 ++--
 src/catch2/benchmark/detail/catch_stats.hpp                | 8 ++++----
 src/catch2/catch_translate_exception.hpp                   | 2 +-
 src/catch2/internal/catch_case_insensitive_comparisons.hpp | 2 +-
 src/catch2/internal/catch_console_width.hpp                | 2 +-
 tests/SelfTest/IntrospectiveTests/Sharding.tests.cpp       | 2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/catch2/benchmark/catch_constructor.hpp b/src/catch2/benchmark/catch_constructor.hpp
index 9da1eaaf..3e2b87e5 100644
--- a/src/catch2/benchmark/catch_constructor.hpp
+++ b/src/catch2/benchmark/catch_constructor.hpp
@@ -51,10 +51,10 @@ namespace Catch {
             private:
                 // If this is a constructor benchmark, destruct the underlying object
                 template <typename U>
-                void destruct_on_exit(std::enable_if_t<Destruct, U>* = 0) { destruct<true>(); }
+                void destruct_on_exit(std::enable_if_t<Destruct, U>* = nullptr) { destruct<true>(); }
                 // Otherwise, don't
                 template <typename U>
-                void destruct_on_exit(std::enable_if_t<!Destruct, U>* = 0) { }
+                void destruct_on_exit(std::enable_if_t<!Destruct, U>* = nullptr) { }
 
                 T& stored_object() {
                     return *static_cast<T*>(static_cast<void*>(&data));
diff --git a/src/catch2/benchmark/detail/catch_stats.hpp b/src/catch2/benchmark/detail/catch_stats.hpp
index 93c4fd60..998616e1 100644
--- a/src/catch2/benchmark/detail/catch_stats.hpp
+++ b/src/catch2/benchmark/detail/catch_stats.hpp
@@ -54,7 +54,7 @@ namespace Catch {
             double mean(Iterator first, Iterator last) {
                 auto count = last - first;
                 double sum = std::accumulate(first, last, 0.);
-                return sum / count;
+                return sum / static_cast<double>(count);
             }
 
             template <typename Estimator, typename Iterator>
@@ -100,7 +100,7 @@ namespace Catch {
                 });
 
                 double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5));
-                int n = static_cast<int>(resample.size());
+                long n = static_cast<long>(resample.size());
                 double prob_n = std::count_if(resample.begin(), resample.end(), [point](double x) { return x < point; }) / static_cast<double>(n);
                 // degenerate case with uniform samples
                 if (prob_n == 0) return { point, point, point, confidence_level };
@@ -108,7 +108,7 @@ namespace Catch {
                 double bias = normal_quantile(prob_n);
                 double z1 = normal_quantile((1. - confidence_level) / 2.);
 
-                auto cumn = [n]( double x ) -> int {
+                auto cumn = [n]( double x ) -> long {
                     return std::lround( normal_cdf( x ) * n );
                 };
                 auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); };
@@ -116,7 +116,7 @@ namespace Catch {
                 double b2 = bias - z1;
                 double a1 = a(b1);
                 double a2 = a(b2);
-                auto lo = static_cast<size_t>((std::max)(cumn(a1), 0));
+                auto lo = static_cast<size_t>((std::max)(cumn(a1), 0l));
                 auto hi = static_cast<size_t>((std::min)(cumn(a2), n - 1));
 
                 return { point, resample[lo], resample[hi], confidence_level };
diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp
index dfd95cd6..4a0be629 100644
--- a/src/catch2/catch_translate_exception.hpp
+++ b/src/catch2/catch_translate_exception.hpp
@@ -81,4 +81,4 @@ namespace Catch {
 #endif
 
 
-#endif // CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED
\ No newline at end of file
+#endif // CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED
diff --git a/src/catch2/internal/catch_case_insensitive_comparisons.hpp b/src/catch2/internal/catch_case_insensitive_comparisons.hpp
index c182e13e..a97b7b4b 100644
--- a/src/catch2/internal/catch_case_insensitive_comparisons.hpp
+++ b/src/catch2/internal/catch_case_insensitive_comparisons.hpp
@@ -27,4 +27,4 @@ namespace Catch {
     } // namespace Detail
 } // namespace Catch
 
-#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED
\ No newline at end of file
+#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED
diff --git a/src/catch2/internal/catch_console_width.hpp b/src/catch2/internal/catch_console_width.hpp
index 52ef0f0e..ad868e33 100644
--- a/src/catch2/internal/catch_console_width.hpp
+++ b/src/catch2/internal/catch_console_width.hpp
@@ -12,4 +12,4 @@
 #define CATCH_CONFIG_CONSOLE_WIDTH 80
 #endif
 
-#endif // CATCH_CONSOLE_WIDTH_HPP_INCLUDED
\ No newline at end of file
+#endif // CATCH_CONSOLE_WIDTH_HPP_INCLUDED
diff --git a/tests/SelfTest/IntrospectiveTests/Sharding.tests.cpp b/tests/SelfTest/IntrospectiveTests/Sharding.tests.cpp
index ec316347..78e4858a 100644
--- a/tests/SelfTest/IntrospectiveTests/Sharding.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/Sharding.tests.cpp
@@ -42,4 +42,4 @@ TEST_CASE("Sharding Function", "[approvals]") {
     for(std::size_t i = 0; i < sizes[shardIndex]; i++) {
         CHECK(result[i] == testContainer[i + startIndex]);
     }
-}
\ No newline at end of file
+}