mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Workaround missing std::nextafter in uClibc
Luckily, the rest of C++11 features seem to be supported... Closes #1739
This commit is contained in:
parent
155274f0df
commit
addf799040
@ -156,8 +156,9 @@ by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`.
|
|||||||
CATCH_CONFIG_ENABLE_BENCHMARKING // Enables the integrated benchmarking features (has a significant effect on compilation speed)
|
CATCH_CONFIG_ENABLE_BENCHMARKING // Enables the integrated benchmarking features (has a significant effect on compilation speed)
|
||||||
CATCH_CONFIG_USE_ASYNC // Force parallel statistical processing of samples during benchmarking
|
CATCH_CONFIG_USE_ASYNC // Force parallel statistical processing of samples during benchmarking
|
||||||
CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output
|
CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output
|
||||||
|
CATCH_CONFIG_GLOBAL_NEXTAFTER // Use nextafter{,f,l} instead of std::nextafter
|
||||||
|
|
||||||
> `CATCH_CONFIG_ANDROID_LOGWRITE` was [introduced](https://github.com/catchorg/Catch2/issues/1743) in Catch X.Y.Z
|
> `CATCH_CONFIG_ANDROID_LOGWRITE` and `CATCH_CONFIG_GLOBAL_NEXTAFTER` were [introduced](https://github.com/catchorg/Catch2/issues/1743) in Catch X.Y.Z
|
||||||
|
|
||||||
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
||||||
|
|
||||||
|
@ -197,6 +197,10 @@
|
|||||||
#define CATCH_CONFIG_COLOUR_NONE
|
#define CATCH_CONFIG_COLOUR_NONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__UCLIBC__)
|
||||||
|
#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Check if string_view is available and usable
|
// Check if string_view is available and usable
|
||||||
// The check is split apart to work around v140 (VS2015) preprocessor issue...
|
// The check is split apart to work around v140 (VS2015) preprocessor issue...
|
||||||
@ -306,6 +310,10 @@
|
|||||||
# define CATCH_CONFIG_ANDROID_LOGWRITE
|
# define CATCH_CONFIG_ANDROID_LOGWRITE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
|
||||||
|
# define CATCH_CONFIG_GLOBAL_NEXTAFTER
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
|
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
|
||||||
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
|
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
|
||||||
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
|
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
|
||||||
|
@ -11,13 +11,16 @@
|
|||||||
#include "catch_to_string.hpp"
|
#include "catch_to_string.hpp"
|
||||||
#include "catch_tostring.h"
|
#include "catch_tostring.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <type_traits>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Matchers {
|
namespace Matchers {
|
||||||
namespace Floating {
|
namespace Floating {
|
||||||
@ -77,10 +80,32 @@ bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) {
|
|||||||
return ulpDiff <= maxUlpDiff;
|
return ulpDiff <= maxUlpDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
float nextafter(float x, float y) {
|
||||||
|
return ::nextafterf(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
double nextafter(double x, double y) {
|
||||||
|
return ::nextafter(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
long double nextafter(long double x, long double y) {
|
||||||
|
return ::nextafterl(x, y);
|
||||||
|
}
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename FP>
|
template <typename FP>
|
||||||
FP step(FP start, FP direction, int steps) {
|
FP step(FP start, FP direction, int steps) {
|
||||||
for (int i = 0; i < steps; ++i) {
|
for (int i = 0; i < steps; ++i) {
|
||||||
|
#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
|
||||||
|
start = Catch::nextafter(start, direction);
|
||||||
|
#else
|
||||||
start = std::nextafter(start, direction);
|
start = std::nextafter(start, direction);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
#include "catch_matchers.h"
|
#include "catch_matchers.h"
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Matchers {
|
namespace Matchers {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user