mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Refactor custom precision in floating point stringification
Also fixup tests.
This commit is contained in:
		| @@ -234,32 +234,16 @@ std::string StringMaker<std::nullptr_t>::convert(std::nullptr_t) { | ||||
|     return "nullptr"; | ||||
| } | ||||
|  | ||||
| int StringMaker<float>::m_precision = 5; | ||||
| int StringMaker<float>::precision = 5; | ||||
|     | ||||
| std::string StringMaker<float>::convert(float value) { | ||||
|     return fpToString(value, m_precision) + 'f'; | ||||
|     return fpToString(value, precision) + 'f'; | ||||
| } | ||||
|  | ||||
| void StringMaker<float>::setPrecision(int precision) { | ||||
|     m_precision = precision; | ||||
| } | ||||
|  | ||||
| int StringMaker<float>::getPrecision() { | ||||
|     return m_precision; | ||||
| } | ||||
|  | ||||
| int StringMaker<double>::m_precision = 10; | ||||
| int StringMaker<double>::precision = 10; | ||||
|      | ||||
| std::string StringMaker<double>::convert(double value) { | ||||
|     return fpToString(value, m_precision); | ||||
| } | ||||
|  | ||||
| void StringMaker<double>::setPrecision(int precision) { | ||||
|     m_precision = precision; | ||||
| } | ||||
|  | ||||
| int StringMaker<double>::getPrecision() { | ||||
|     return m_precision; | ||||
|     return fpToString(value, precision); | ||||
| } | ||||
|  | ||||
| std::string ratio_string<std::atto>::symbol() { return "a"; } | ||||
|   | ||||
| @@ -261,19 +261,13 @@ namespace Catch { | ||||
|     template<> | ||||
|     struct StringMaker<float> { | ||||
|         static std::string convert(float value); | ||||
|         static void setPrecision(int precision); | ||||
|         static int getPrecision(); | ||||
|     private: | ||||
|         static int m_precision; | ||||
|         static int precision; | ||||
|     }; | ||||
|  | ||||
|     template<> | ||||
|     struct StringMaker<double> { | ||||
|         static std::string convert(double value); | ||||
|         static void setPrecision(int precision); | ||||
|         static int getPrecision(); | ||||
|     private: | ||||
|         static int m_precision; | ||||
|         static int precision; | ||||
|     }; | ||||
|  | ||||
|     template <typename T> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský