aboutsummaryrefslogtreecommitdiff
path: root/tests/framework/Utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/framework/Utils.h')
-rw-r--r--tests/framework/Utils.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/framework/Utils.h b/tests/framework/Utils.h
index 4f4b6fce56..c0442cf9af 100644
--- a/tests/framework/Utils.h
+++ b/tests/framework/Utils.h
@@ -155,15 +155,17 @@ inline std::string tolower(std::string string)
/** Create a string with the arithmetic value in full precision.
*
- * @param val Arithmetic value
+ * @param val Arithmetic value
+ * @param decimal_places How many decimal places to show
*
* @return String with the arithmetic value.
*/
template <typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
-inline std::string arithmetic_to_string(T val)
+inline std::string arithmetic_to_string(T val, int decimal_places = 0)
{
std::stringstream ss;
- ss.precision(std::numeric_limits<T>::digits10 + 1);
+ ss << std::fixed;
+ ss.precision((decimal_places) ? decimal_places : std::numeric_limits<T>::digits10 + 1);
ss << val;
return ss.str();
}