Use internal linkage for float stringification helper

This commit is contained in:
Martin Hořeňovský 2020-05-10 06:54:19 +02:00
parent cb25c4a8a3
commit a595066ff9
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -41,25 +41,6 @@ namespace Detail {
return value ? Little : Big;
}
};
}
std::string rawMemoryToString( const void *object, std::size_t size ) {
// Reverse order for little endian architectures
int i = 0, end = static_cast<int>( size ), inc = 1;
if( Endianness::which() == Endianness::Little ) {
i = end-1;
end = inc = -1;
}
unsigned char const *bytes = static_cast<unsigned char const *>(object);
ReusableStringStream rss;
rss << "0x" << std::setfill('0') << std::hex;
for( ; i != end; i += inc )
rss << std::setw(2) << static_cast<unsigned>(bytes[i]);
return rss.str();
}
}
template<typename T>
std::string fpToString(T value, int precision) {
@ -80,6 +61,25 @@ std::string fpToString( T value, int precision ) {
}
return d;
}
} // end unnamed namespace
std::string rawMemoryToString( const void *object, std::size_t size ) {
// Reverse order for little endian architectures
int i = 0, end = static_cast<int>( size ), inc = 1;
if( Endianness::which() == Endianness::Little ) {
i = end-1;
end = inc = -1;
}
unsigned char const *bytes = static_cast<unsigned char const *>(object);
ReusableStringStream rss;
rss << "0x" << std::setfill('0') << std::hex;
for( ; i != end; i += inc )
rss << std::setw(2) << static_cast<unsigned>(bytes[i]);
return rss.str();
}
} // end Detail namespace
//// ======================================================= ////
@ -228,13 +228,13 @@ std::string StringMaker<unsigned char>::convert(unsigned char c) {
int StringMaker<float>::precision = 5;
std::string StringMaker<float>::convert(float value) {
return fpToString(value, precision) + 'f';
return Detail::fpToString(value, precision) + 'f';
}
int StringMaker<double>::precision = 10;
std::string StringMaker<double>::convert(double value) {
return fpToString(value, precision);
return Detail::fpToString(value, precision);
}
} // end namespace Catch