mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 08:25:58 +01:00
Adding delta infinity & nan checks & tests
This commit is contained in:
22
src/unity.c
22
src/unity.c
@@ -954,6 +954,17 @@ void UnityAssertWithinFloatArray(const UNITY_FLOAT delta,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isinf(in_delta))
|
||||||
|
{
|
||||||
|
return; /* Arrays will be force equal with infinite delta */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isnan(in_delta))
|
||||||
|
{
|
||||||
|
/* Delta must be correct number */
|
||||||
|
UnityPrintPointlessAndBail();
|
||||||
|
}
|
||||||
|
|
||||||
if (expected == actual)
|
if (expected == actual)
|
||||||
{
|
{
|
||||||
return; /* Both are NULL or same pointer */
|
return; /* Both are NULL or same pointer */
|
||||||
@@ -1170,6 +1181,17 @@ void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isinf(in_delta))
|
||||||
|
{
|
||||||
|
return; /* Arrays will be force equal with infinite delta */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isnan(in_delta))
|
||||||
|
{
|
||||||
|
/* Delta must be correct number */
|
||||||
|
UnityPrintPointlessAndBail();
|
||||||
|
}
|
||||||
|
|
||||||
if (expected == actual)
|
if (expected == actual)
|
||||||
{
|
{
|
||||||
return; /* Both are NULL or same pointer */
|
return; /* Both are NULL or same pointer */
|
||||||
|
|||||||
@@ -1049,6 +1049,22 @@ void testDoubleArraysWithin(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testDoubleArraysWithinUnusualDelta(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
double p0[] = {-INFINITY, -8.0, 25.4, -0.123};
|
||||||
|
double p1[] = {INFINITY, 10.1};
|
||||||
|
|
||||||
|
TEST_ASSERT_DOUBLE_ARRAY_WITHIN(INFINITY, p0, p1, 2);
|
||||||
|
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_DOUBLE_ARRAY_WITHIN(NAN, p0, p0, 4);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void testEqualDoubleEachEqual(void)
|
void testEqualDoubleEachEqual(void)
|
||||||
{
|
{
|
||||||
#ifdef UNITY_EXCLUDE_DOUBLE
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
|||||||
@@ -1047,6 +1047,22 @@ void testFloatArraysWithin(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testFloatArraysWithinUnusualDelta(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_FLOAT
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
float p0[] = {(float)-INFINITY, -8.0f, 25.4f, -0.123f};
|
||||||
|
float p1[] = {(float)INFINITY, 10.1f};
|
||||||
|
|
||||||
|
TEST_ASSERT_FLOAT_ARRAY_WITHIN(INFINITY, p0, p1, 2);
|
||||||
|
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_FLOAT_ARRAY_WITHIN(NAN, p0, p0, 4);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void testEqualFloatEachEqual(void)
|
void testEqualFloatEachEqual(void)
|
||||||
{
|
{
|
||||||
#ifdef UNITY_EXCLUDE_FLOAT
|
#ifdef UNITY_EXCLUDE_FLOAT
|
||||||
|
|||||||
Reference in New Issue
Block a user