mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-07-15 00:52:46 +08:00
Merge pull request #226 from jsalling/feature/nan-not-eq-nan
Add option to set NaN not equal NaN for floating point assertions
This commit is contained in:
@ -619,12 +619,17 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
|||||||
/* Wrap this define in a function with variable types as float or double */
|
/* Wrap this define in a function with variable types as float or double */
|
||||||
#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \
|
#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \
|
||||||
if (isinf(expected) && isinf(actual) && (isneg(expected) == isneg(actual))) return 1; \
|
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; \
|
diff = actual - expected; \
|
||||||
if (diff < 0.0f) diff = 0.0f - diff; \
|
if (diff < 0.0f) diff = 0.0f - diff; \
|
||||||
if (delta < 0.0f) delta = 0.0f - delta; \
|
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 */
|
/* 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
|
#ifndef UNITY_EXCLUDE_FLOAT
|
||||||
static int UnityFloatsWithin(_UF delta, _UF expected, _UF actual)
|
static int UnityFloatsWithin(_UF delta, _UF expected, _UF actual)
|
||||||
|
@ -3713,7 +3713,7 @@ void testNotEqualDoubleArraysNegative3(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void testNotEqualDoubleArraysNaN(void)
|
void testEqualDoubleArraysNaN(void)
|
||||||
{
|
{
|
||||||
#ifdef UNITY_EXCLUDE_DOUBLE
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
TEST_IGNORE();
|
TEST_IGNORE();
|
||||||
|
Reference in New Issue
Block a user