1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 00:15:58 +01:00

Merge pull request #375 from jlindgren90/int-min-printing

Fix undefined behavior when printing INT_MIN/INT64_MIN. (Thanks @jlindgren90 !)
This commit is contained in:
Mark VanderVoord
2018-11-28 15:23:03 -05:00
committed by GitHub

View File

@@ -183,7 +183,7 @@ void UnityPrintNumber(const UNITY_INT number_to_print)
{
/* A negative number, including MIN negative */
UNITY_OUTPUT_CHAR('-');
number = (UNITY_UINT)(-number_to_print);
number = -number;
}
UnityPrintNumberUnsigned(number);
}
@@ -1019,22 +1019,22 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta,
{
if (actual > expected)
{
Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta);
Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta);
}
else
{
Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta);
Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta);
}
}
else
{
if ((UNITY_UINT)actual > (UNITY_UINT)expected)
{
Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta);
Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta);
}
else
{
Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta);
Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta);
}
}