mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-16 10:42:25 +01:00
added long double support for printing values
This commit is contained in:
parent
531a149ae7
commit
d7f3d60cdc
@ -18,6 +18,9 @@ namespace Catch {
|
||||
bool isnan(double d) {
|
||||
return std::isnan(d);
|
||||
}
|
||||
bool isnan(long double d) {
|
||||
return std::isnan(d);
|
||||
}
|
||||
#else
|
||||
// For now we only use this for embarcadero
|
||||
bool isnan(float f) {
|
||||
@ -26,6 +29,9 @@ namespace Catch {
|
||||
bool isnan(double d) {
|
||||
return std::_isnan(d);
|
||||
}
|
||||
bool isnan(long double d) {
|
||||
return std::_isnan(d);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -10,6 +10,7 @@
|
||||
namespace Catch {
|
||||
bool isnan(float f);
|
||||
bool isnan(double d);
|
||||
bool isnan(long double d);
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_POLYFILLS_HPP_INCLUDED
|
||||
|
@ -73,7 +73,8 @@ std::string fpToString( T value, int precision ) {
|
||||
|
||||
ReusableStringStream rss;
|
||||
rss << std::setprecision( precision )
|
||||
<< std::fixed
|
||||
<< std::fixed
|
||||
// << std::scientific // would be nice if we could switch between these two !
|
||||
<< value;
|
||||
std::string d = rss.str();
|
||||
std::size_t i = d.find_last_not_of( '0' );
|
||||
@ -250,6 +251,13 @@ std::string StringMaker<double>::convert(double value) {
|
||||
return fpToString(value, precision);
|
||||
}
|
||||
|
||||
int StringMaker<long double>::precision = 15;
|
||||
|
||||
std::string StringMaker<long double>::convert(long double value) {
|
||||
return fpToString(value, precision);
|
||||
}
|
||||
|
||||
|
||||
std::string ratio_string<std::atto>::symbol() { return "a"; }
|
||||
std::string ratio_string<std::femto>::symbol() { return "f"; }
|
||||
std::string ratio_string<std::pico>::symbol() { return "p"; }
|
||||
|
@ -276,6 +276,12 @@ namespace Catch {
|
||||
static int precision;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct StringMaker<long double> {
|
||||
static std::string convert(long double value);
|
||||
static int precision;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct StringMaker<T*> {
|
||||
template <typename U>
|
||||
|
Loading…
Reference in New Issue
Block a user