| 2036 | |
| 2037 | template<typename T> |
| 2038 | std::string fpToString(T value, int precision) { |
| 2039 | if (Catch::isnan(value)) { |
| 2040 | return "nan"; |
| 2041 | } |
| 2042 | |
| 2043 | ReusableStringStream rss; |
| 2044 | rss << std::setprecision(precision) |
| 2045 | << std::fixed |
| 2046 | << value; |
| 2047 | std::string d = rss.str(); |
| 2048 | std::size_t i = d.find_last_not_of('0'); |
| 2049 | if (i != std::string::npos && i != d.size() - 1) { |
| 2050 | if (d[i] == '.') |
| 2051 | i++; |
| 2052 | d = d.substr(0, i + 1); |
| 2053 | } |
| 2054 | return d; |
| 2055 | } |
| 2056 | } // end unnamed namespace |
| 2057 | |
| 2058 | std::size_t catch_strnlen( const char* str, std::size_t n ) { |