diff --git a/src/unity.c b/src/unity.c index 58e93db8bd393400e639e4adeae0a3dc79a9a7cf..765e4e46bf2ad47d32499c305e1f6ffa5e0e72f2 100644 --- a/src/unity.c +++ b/src/unity.c @@ -619,12 +619,17 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, /* 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) && (isneg(expected) == isneg(actual))) return 1; \ - if (isnan(expected) && isnan(actual)) return 1; \ + if (UNITY_NAN_CHECK) return 1; \ diff = actual - expected; \ if (diff < 0.0f) diff = 0.0f - diff; \ if (delta < 0.0f) delta = 0.0f - delta; \ - return !(isnan(diff) || isinf(diff) || (delta < diff)); + return !(isnan(diff) || isinf(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) +#else + #define UNITY_NAN_CHECK 0 +#endif #ifndef UNITY_EXCLUDE_FLOAT static int UnityFloatsWithin(_UF delta, _UF expected, _UF actual) diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 823016353379b0818011dd561b755b987e6bd9e9..e66de4d0c594658dffd5fcb71e5e0947c0721d02 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -3713,7 +3713,7 @@ void testNotEqualDoubleArraysNegative3(void) #endif } -void testNotEqualDoubleArraysNaN(void) +void testEqualDoubleArraysNaN(void) { #ifdef UNITY_EXCLUDE_DOUBLE TEST_IGNORE();