mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-25 10:13:12 +08:00
Merge pull request #189 from rikvdh/master
Thanks @rikvdh for catching some instances where we should have been using isnan and such that were missing!
This commit is contained in:
10
src/unity.c
10
src/unity.c
@ -668,13 +668,13 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
|
|||||||
{
|
{
|
||||||
diff = *ptr_expected - *ptr_actual;
|
diff = *ptr_expected - *ptr_actual;
|
||||||
if (diff < 0.0f)
|
if (diff < 0.0f)
|
||||||
diff = 0.0f - diff;
|
diff = 0.0f - diff;
|
||||||
tol = UNITY_FLOAT_PRECISION * *ptr_expected;
|
tol = UNITY_FLOAT_PRECISION * *ptr_expected;
|
||||||
if (tol < 0.0f)
|
if (tol < 0.0f)
|
||||||
tol = 0.0f - tol;
|
tol = 0.0f - tol;
|
||||||
|
|
||||||
//This first part of this condition will catch any NaN or Infinite values
|
//This first part of this condition will catch any NaN or Infinite values
|
||||||
if ((diff * 0.0f != 0.0f) || (diff > tol))
|
if (isnan(diff) || isinf(diff) || (diff > tol))
|
||||||
{
|
{
|
||||||
UnityTestResultsFailBegin(lineNumber);
|
UnityTestResultsFailBegin(lineNumber);
|
||||||
UnityPrint(UnityStrElement);
|
UnityPrint(UnityStrElement);
|
||||||
@ -717,7 +717,7 @@ void UnityAssertFloatsWithin(const _UF delta,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This first part of this condition will catch any NaN or Infinite values
|
//This first part of this condition will catch any NaN or Infinite values
|
||||||
if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
|
if (isnan(diff) || isinf(diff) || (pos_delta < diff))
|
||||||
{
|
{
|
||||||
UnityTestResultsFailBegin(lineNumber);
|
UnityTestResultsFailBegin(lineNumber);
|
||||||
#ifdef UNITY_FLOAT_VERBOSE
|
#ifdef UNITY_FLOAT_VERBOSE
|
||||||
@ -838,7 +838,7 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
|
|||||||
tol = 0.0 - tol;
|
tol = 0.0 - tol;
|
||||||
|
|
||||||
//This first part of this condition will catch any NaN or Infinite values
|
//This first part of this condition will catch any NaN or Infinite values
|
||||||
if ((diff * 0.0 != 0.0) || (diff > tol))
|
if (isnan(diff) || isinf(diff) || (diff > tol))
|
||||||
{
|
{
|
||||||
UnityTestResultsFailBegin(lineNumber);
|
UnityTestResultsFailBegin(lineNumber);
|
||||||
UnityPrint(UnityStrElement);
|
UnityPrint(UnityStrElement);
|
||||||
@ -881,7 +881,7 @@ void UnityAssertDoublesWithin(const _UD delta,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This first part of this condition will catch any NaN or Infinite values
|
//This first part of this condition will catch any NaN or Infinite values
|
||||||
if ((diff * 0.0 != 0.0) || (pos_delta < diff))
|
if (isnan(diff) || isinf(diff) || (pos_delta < diff))
|
||||||
{
|
{
|
||||||
UnityTestResultsFailBegin(lineNumber);
|
UnityTestResultsFailBegin(lineNumber);
|
||||||
#ifdef UNITY_DOUBLE_VERBOSE
|
#ifdef UNITY_DOUBLE_VERBOSE
|
||||||
|
Reference in New Issue
Block a user