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) {
|
bool isnan(double d) {
|
||||||
return std::isnan(d);
|
return std::isnan(d);
|
||||||
}
|
}
|
||||||
|
bool isnan(long double d) {
|
||||||
|
return std::isnan(d);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// For now we only use this for embarcadero
|
// For now we only use this for embarcadero
|
||||||
bool isnan(float f) {
|
bool isnan(float f) {
|
||||||
@ -26,6 +29,9 @@ namespace Catch {
|
|||||||
bool isnan(double d) {
|
bool isnan(double d) {
|
||||||
return std::_isnan(d);
|
return std::_isnan(d);
|
||||||
}
|
}
|
||||||
|
bool isnan(long double d) {
|
||||||
|
return std::_isnan(d);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
bool isnan(float f);
|
bool isnan(float f);
|
||||||
bool isnan(double d);
|
bool isnan(double d);
|
||||||
|
bool isnan(long double d);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_POLYFILLS_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_POLYFILLS_HPP_INCLUDED
|
||||||
|
@ -74,6 +74,7 @@ std::string fpToString( T value, int precision ) {
|
|||||||
ReusableStringStream rss;
|
ReusableStringStream rss;
|
||||||
rss << std::setprecision( precision )
|
rss << std::setprecision( precision )
|
||||||
<< std::fixed
|
<< std::fixed
|
||||||
|
// << std::scientific // would be nice if we could switch between these two !
|
||||||
<< value;
|
<< value;
|
||||||
std::string d = rss.str();
|
std::string d = rss.str();
|
||||||
std::size_t i = d.find_last_not_of( '0' );
|
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);
|
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::atto>::symbol() { return "a"; }
|
||||||
std::string ratio_string<std::femto>::symbol() { return "f"; }
|
std::string ratio_string<std::femto>::symbol() { return "f"; }
|
||||||
std::string ratio_string<std::pico>::symbol() { return "p"; }
|
std::string ratio_string<std::pico>::symbol() { return "p"; }
|
||||||
|
@ -276,6 +276,12 @@ namespace Catch {
|
|||||||
static int precision;
|
static int precision;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct StringMaker<long double> {
|
||||||
|
static std::string convert(long double value);
|
||||||
|
static int precision;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct StringMaker<T*> {
|
struct StringMaker<T*> {
|
||||||
template <typename U>
|
template <typename U>
|
||||||
|
Loading…
Reference in New Issue
Block a user