mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-25 01:11:36 +01:00
Update change log and known issues.
Fix bug with infinity and NaN handling.
This commit is contained in:
34
src/unity.c
34
src/unity.c
@@ -356,11 +356,11 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
|
||||
{
|
||||
UnityPrint("0");
|
||||
}
|
||||
else if (isnan(number))
|
||||
else if (UNITY_IS_NAN(number))
|
||||
{
|
||||
UnityPrint("nan");
|
||||
}
|
||||
else if (isinf(number))
|
||||
else if (UNITY_IS_INF(number))
|
||||
{
|
||||
UnityPrint("inf");
|
||||
}
|
||||
@@ -895,15 +895,15 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
||||
#ifndef UNITY_EXCLUDE_FLOAT
|
||||
/* Wrap this define in a function with variable types as float or double */
|
||||
#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \
|
||||
if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \
|
||||
if (UNITY_IS_INF(expected) && UNITY_IS_INF(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \
|
||||
if (UNITY_NAN_CHECK) return 1; \
|
||||
(diff) = (actual) - (expected); \
|
||||
if ((diff) < 0) (diff) = -(diff); \
|
||||
if ((delta) < 0) (delta) = -(delta); \
|
||||
return !(isnan(diff) || isinf(diff) || ((diff) > (delta)))
|
||||
return !(UNITY_IS_NAN(diff) || UNITY_IS_INF(diff) || ((diff) > (delta)))
|
||||
/* This first part of this condition will catch any NaN or Infinite values */
|
||||
#ifndef UNITY_NAN_NOT_EQUAL_NAN
|
||||
#define UNITY_NAN_CHECK isnan(expected) && isnan(actual)
|
||||
#define UNITY_NAN_CHECK UNITY_IS_NAN(expected) && UNITY_IS_NAN(actual)
|
||||
#else
|
||||
#define UNITY_NAN_CHECK 0
|
||||
#endif
|
||||
@@ -954,12 +954,12 @@ void UnityAssertWithinFloatArray(const UNITY_FLOAT delta,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (isinf(in_delta))
|
||||
if (UNITY_IS_INF(in_delta))
|
||||
{
|
||||
return; /* Arrays will be force equal with infinite delta */
|
||||
}
|
||||
|
||||
if (isnan(in_delta))
|
||||
if (UNITY_IS_NAN(in_delta))
|
||||
{
|
||||
/* Delta must be correct number */
|
||||
UnityPrintPointlessAndBail();
|
||||
@@ -1098,21 +1098,21 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual,
|
||||
{
|
||||
case UNITY_FLOAT_IS_INF:
|
||||
case UNITY_FLOAT_IS_NOT_INF:
|
||||
is_trait = isinf(actual) && (actual > 0);
|
||||
is_trait = UNITY_IS_INF(actual) && (actual > 0);
|
||||
break;
|
||||
case UNITY_FLOAT_IS_NEG_INF:
|
||||
case UNITY_FLOAT_IS_NOT_NEG_INF:
|
||||
is_trait = isinf(actual) && (actual < 0);
|
||||
is_trait = UNITY_IS_INF(actual) && (actual < 0);
|
||||
break;
|
||||
|
||||
case UNITY_FLOAT_IS_NAN:
|
||||
case UNITY_FLOAT_IS_NOT_NAN:
|
||||
is_trait = isnan(actual) ? 1 : 0;
|
||||
is_trait = UNITY_IS_NAN(actual) ? 1 : 0;
|
||||
break;
|
||||
|
||||
case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
|
||||
case UNITY_FLOAT_IS_NOT_DET:
|
||||
is_trait = !isinf(actual) && !isnan(actual);
|
||||
is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual);
|
||||
break;
|
||||
|
||||
case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */
|
||||
@@ -1182,12 +1182,12 @@ void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (isinf(in_delta))
|
||||
if (UNITY_IS_INF(in_delta))
|
||||
{
|
||||
return; /* Arrays will be force equal with infinite delta */
|
||||
}
|
||||
|
||||
if (isnan(in_delta))
|
||||
if (UNITY_IS_NAN(in_delta))
|
||||
{
|
||||
/* Delta must be correct number */
|
||||
UnityPrintPointlessAndBail();
|
||||
@@ -1325,21 +1325,21 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
|
||||
{
|
||||
case UNITY_FLOAT_IS_INF:
|
||||
case UNITY_FLOAT_IS_NOT_INF:
|
||||
is_trait = isinf(actual) && (actual > 0);
|
||||
is_trait = UNITY_IS_INF(actual) && (actual > 0);
|
||||
break;
|
||||
case UNITY_FLOAT_IS_NEG_INF:
|
||||
case UNITY_FLOAT_IS_NOT_NEG_INF:
|
||||
is_trait = isinf(actual) && (actual < 0);
|
||||
is_trait = UNITY_IS_INF(actual) && (actual < 0);
|
||||
break;
|
||||
|
||||
case UNITY_FLOAT_IS_NAN:
|
||||
case UNITY_FLOAT_IS_NOT_NAN:
|
||||
is_trait = isnan(actual) ? 1 : 0;
|
||||
is_trait = UNITY_IS_NAN(actual) ? 1 : 0;
|
||||
break;
|
||||
|
||||
case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
|
||||
case UNITY_FLOAT_IS_NOT_DET:
|
||||
is_trait = !isinf(actual) && !isnan(actual);
|
||||
is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual);
|
||||
break;
|
||||
|
||||
case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */
|
||||
|
||||
Reference in New Issue
Block a user