mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-30 03:34:27 +01:00
Expanded NaN and Infinity handling to doubles.
This commit is contained in:
@@ -673,7 +673,8 @@ void UnityAssertDoublesWithin(const _UD delta,
|
|||||||
pos_delta = 0.0f - pos_delta;
|
pos_delta = 0.0f - pos_delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos_delta < diff)
|
//This first part of this condition will catch any NaN or Infinite values
|
||||||
|
if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
|
||||||
{
|
{
|
||||||
UnityTestResultsFailBegin(lineNumber);
|
UnityTestResultsFailBegin(lineNumber);
|
||||||
#ifdef UNITY_DOUBLE_VERBOSE
|
#ifdef UNITY_DOUBLE_VERBOSE
|
||||||
|
|||||||
@@ -2526,6 +2526,105 @@ void testDoublesNotEqualNegative2(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualActualNaN(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(85.963f, 0.0f / 0.0f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualExpectedNaN(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(0.0f / 0.0f, 85.963f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualBothNaN(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(0.0f / 0.0f, 0.0f / 0.0f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualInfNaN(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(1.0f / 0.0f, 0.0f / 0.0f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualNaNInf(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(0.0f / 0.0f, 1.0f / 0.0f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualActualInf(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(321.642f, 1.0f / 0.0f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualExpectedInf(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(1.0f / 0.0f, 321.642f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualBothInf(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(1.0f / 0.0f, 1.0f / 0.0f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDoublesNotEqualPlusMinusInf(void)
|
||||||
|
{
|
||||||
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
TEST_IGNORE();
|
||||||
|
#else
|
||||||
|
EXPECT_ABORT_BEGIN
|
||||||
|
TEST_ASSERT_EQUAL_DOUBLE(1.0f / 0.0f, -1.0f / 0.0f);
|
||||||
|
VERIFY_FAILS_END
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void testEqualDoubleArrays(void)
|
void testEqualDoubleArrays(void)
|
||||||
{
|
{
|
||||||
#ifdef UNITY_EXCLUDE_DOUBLE
|
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||||
|
|||||||
Reference in New Issue
Block a user