From c17705358f7ce11c1a00c2317dfa2c49a2807e96 Mon Sep 17 00:00:00 2001
From: Matias Devenuta <mdv@satellogic.com>
Date: Wed, 24 Feb 2016 19:52:30 -0300
Subject: [PATCH] UnityPrintFloat(): bigger temporal buffer

With a buffer long enough, no truncation should be neccesary to format floats.

Buffer length is user settable by defining UNITY_VERBOSE_NUMBER_MAX_LENGTH,
otherwise a sensible default is used based on desired precision.

See: http://stackoverflow.com/a/7235717
---
 src/unity.c | 11 ++++++++++-
 src/unity.h |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/unity.c b/src/unity.c
index 45e34ea..22a981b 100644
--- a/src/unity.c
+++ b/src/unity.c
@@ -280,9 +280,18 @@ void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
 //-----------------------------------------------
 #ifdef UNITY_FLOAT_VERBOSE
 #include <stdio.h>
+
+#ifndef UNITY_VERBOSE_NUMBER_MAX_LENGTH
+# ifdef UNITY_DOUBLE_VERBOSE
+#  define UNITY_VERBOSE_NUMBER_MAX_LENGTH 317
+# else
+#  define UNITY_VERBOSE_NUMBER_MAX_LENGTH 47
+# endif
+#endif
+
 void UnityPrintFloat(_UF number)
 {
-    char TempBuffer[32];
+    char TempBuffer[UNITY_VERBOSE_NUMBER_MAX_LENGTH + 1];
     snprintf(TempBuffer, sizeof(TempBuffer), "%.6f", number);
     UnityPrint(TempBuffer);
 }
diff --git a/src/unity.h b/src/unity.h
index 9f80495..adb90cf 100644
--- a/src/unity.h
+++ b/src/unity.h
@@ -44,6 +44,7 @@ void tearDown(void);
 //     - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE
 //     - define UNITY_DOUBLE_TYPE to specify something other than double
 //     - define UNITY_DOUBLE_VERBOSE to print floating point values in errors (uses sprintf)
+//     - define UNITY_VERBOSE_NUMBER_MAX_LENGTH to change maximum length of printed numbers (used by sprintf)
 
 // Output
 //     - by default, Unity prints to standard out with putchar.  define UNITY_OUTPUT_CHAR(a) with a different function if desired