Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-05-02 12:52:55 +0200
committerMartin Hořeňovský2022-05-03 13:53:55 +0200
commit198808a24e252bf049df24c2f3d4b4d69c892a39 (patch)
tree3272482d7fa672a4c3b70c4c2fdd72f08e03bae0 /src
parent198713e5dc2c1adc8f28bdd43c9e66a679cf8d8d (diff)
downloadcatch3-198808a24e252bf049df24c2f3d4b4d69c892a39.tar.gz
Misc cleanups from exploring Clang warnings
Diffstat (limited to 'src')
-rw-r--r--src/catch2/benchmark/catch_constructor.hpp4
-rw-r--r--src/catch2/benchmark/detail/catch_stats.hpp8
-rw-r--r--src/catch2/catch_translate_exception.hpp2
-rw-r--r--src/catch2/internal/catch_case_insensitive_comparisons.hpp2
-rw-r--r--src/catch2/internal/catch_console_width.hpp2
5 files changed, 9 insertions, 9 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