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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-11-18 16:17:49 +0100
committerMartin Hořeňovský2023-12-10 18:44:06 +0100
commitbfd9f0f5a67c0127b25ac82eb828f6ab71aaae1e (patch)
treea0efb539745f0ca7186bacc24da48bea66669411 /src/catch2
parent9a1e73568c86644bda84d2d8c719955a050bb3e3 (diff)
downloadcatch3-bfd9f0f5a67c0127b25ac82eb828f6ab71aaae1e.tar.gz
Move nextafter polyfill to polyfills.hpp
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/internal/catch_polyfills.cpp8
-rw-r--r--src/catch2/internal/catch_polyfills.hpp5
-rw-r--r--src/catch2/matchers/catch_matchers_floating_point.cpp15
3 files changed, 13 insertions, 15 deletions
diff --git a/src/catch2/internal/catch_polyfills.cpp b/src/catch2/internal/catch_polyfills.cpp
index 96efad5d..776c2243 100644
--- a/src/catch2/internal/catch_polyfills.cpp
+++ b/src/catch2/internal/catch_polyfills.cpp
@@ -31,4 +31,12 @@ namespace Catch {
}
#endif
+#if !defined( CATCH_CONFIG_GLOBAL_NEXTAFTER )
+ float nextafter( float x, float y ) { return std::nextafter( x, y ); }
+ double nextafter( double x, double y ) { return std::nextafter( x, y ); }
+#else
+ float nextafter( float x, float y ) { return ::nextafterf( x, y ); }
+ double nextafter( double x, double y ) { return ::nextafter( x, y ); }
+#endif
+
} // end namespace Catch
diff --git a/src/catch2/internal/catch_polyfills.hpp b/src/catch2/internal/catch_polyfills.hpp
index 23a9332b..4503f8f2 100644
--- a/src/catch2/internal/catch_polyfills.hpp
+++ b/src/catch2/internal/catch_polyfills.hpp
@@ -9,8 +9,13 @@
#define CATCH_POLYFILLS_HPP_INCLUDED
namespace Catch {
+
bool isnan(float f);
bool isnan(double d);
+
+ float nextafter(float x, float y);
+ double nextafter(double x, double y);
+
}
#endif // CATCH_POLYFILLS_HPP_INCLUDED
diff --git a/src/catch2/matchers/catch_matchers_floating_point.cpp b/src/catch2/matchers/catch_matchers_floating_point.cpp
index 6e596466..206332ef 100644
--- a/src/catch2/matchers/catch_matchers_floating_point.cpp
+++ b/src/catch2/matchers/catch_matchers_floating_point.cpp
@@ -38,26 +38,11 @@ namespace {
return ulpDist <= maxUlpDiff;
}
-#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
-
- float nextafter(float x, float y) {
- return ::nextafterf(x, y);
- }
-
- double nextafter(double x, double y) {
- return ::nextafter(x, y);
- }
-
-#endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^
template <typename FP>
FP step(FP start, FP direction, uint64_t steps) {
for (uint64_t i = 0; i < steps; ++i) {
-#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
start = Catch::nextafter(start, direction);
-#else
- start = std::nextafter(start, direction);
-#endif
}
return start;
}