mirror of
https://github.com/catchorg/Catch2.git
synced 2025-03-31 07:34:46 +02:00
Fix compilation error with CATCH_CONFIG_GLOBAL_NEXTAFTER
Wrong nesting of namespaces resulted in the `Catch` namespace being ambigous between `::Catch` and `::{anon}::Catch` namespaces. This should fix it. Closes #1761
This commit is contained in:
parent
c38a5caa2e
commit
4bd2c3ad6a
@ -22,16 +22,6 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Matchers {
|
|
||||||
namespace Floating {
|
|
||||||
enum class FloatingPointKind : uint8_t {
|
|
||||||
Float,
|
|
||||||
Double
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int32_t convert(float f) {
|
int32_t convert(float f) {
|
||||||
@ -67,10 +57,16 @@ bool almostEqualUlps(FP lhs, FP rhs, uint64_t maxUlpDiff) {
|
|||||||
auto ulpDiff = std::abs(lc - rc);
|
auto ulpDiff = std::abs(lc - rc);
|
||||||
return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff;
|
return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
|
#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
|
||||||
|
|
||||||
namespace Catch {
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
// The long double overload is currently unused
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-function"
|
||||||
|
#endif
|
||||||
|
|
||||||
float nextafter(float x, float y) {
|
float nextafter(float x, float y) {
|
||||||
return ::nextafterf(x, y);
|
return ::nextafterf(x, y);
|
||||||
}
|
}
|
||||||
@ -82,10 +78,15 @@ namespace Catch {
|
|||||||
long double nextafter(long double x, long double y) {
|
long double nextafter(long double x, long double y) {
|
||||||
return ::nextafterl(x, y);
|
return ::nextafterl(x, y);
|
||||||
}
|
}
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
template <typename FP>
|
template <typename FP>
|
||||||
FP step(FP start, FP direction, uint64_t steps) {
|
FP step(FP start, FP direction, uint64_t steps) {
|
||||||
for (uint64_t i = 0; i < steps; ++i) {
|
for (uint64_t i = 0; i < steps; ++i) {
|
||||||
@ -97,13 +98,17 @@ FP step(FP start, FP direction, uint64_t steps) {
|
|||||||
}
|
}
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
namespace Matchers {
|
namespace Matchers {
|
||||||
namespace Floating {
|
namespace Floating {
|
||||||
|
|
||||||
|
enum class FloatingPointKind : uint8_t {
|
||||||
|
Float,
|
||||||
|
Double
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
WithinAbsMatcher::WithinAbsMatcher(double target, double margin)
|
WithinAbsMatcher::WithinAbsMatcher(double target, double margin)
|
||||||
:m_target{ target }, m_margin{ margin } {
|
:m_target{ target }, m_margin{ margin } {
|
||||||
CATCH_ENFORCE(margin >= 0, "Invalid margin: " << margin << '.'
|
CATCH_ENFORCE(margin >= 0, "Invalid margin: " << margin << '.'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user