mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-12-17 05:54:07 +08:00
Add NOT_EQUAL* and NOT_WITHIN* checks for floats and doubles
This commit is contained in:
42
src/unity.c
42
src/unity.c
@@ -977,6 +977,27 @@ void UnityAssertFloatsWithin(const UNITY_FLOAT delta,
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta,
|
||||
const UNITY_FLOAT expected,
|
||||
const UNITY_FLOAT actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber)
|
||||
{
|
||||
RETURN_IF_FAIL_OR_IGNORE;
|
||||
|
||||
if (UnityFloatsWithin(delta, expected, actual))
|
||||
{
|
||||
UnityTestResultsFailBegin(lineNumber);
|
||||
UnityPrint(UnityStrExpected);
|
||||
UnityPrintFloat((UNITY_DOUBLE)expected);
|
||||
UnityPrint(UnityStrNotEqual);
|
||||
UnityPrintFloat((UNITY_DOUBLE)actual);
|
||||
UnityAddMsgIfSpecified(msg);
|
||||
UNITY_FAIL_AND_BAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold,
|
||||
const UNITY_FLOAT actual,
|
||||
@@ -1145,6 +1166,27 @@ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta,
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta,
|
||||
const UNITY_DOUBLE expected,
|
||||
const UNITY_DOUBLE actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber)
|
||||
{
|
||||
RETURN_IF_FAIL_OR_IGNORE;
|
||||
|
||||
if (UnityDoublesWithin(delta, expected, actual))
|
||||
{
|
||||
UnityTestResultsFailBegin(lineNumber);
|
||||
UnityPrint(UnityStrExpected);
|
||||
UnityPrintFloat((UNITY_DOUBLE)expected);
|
||||
UnityPrint(UnityStrNotEqual);
|
||||
UnityPrintFloat((UNITY_DOUBLE)actual);
|
||||
UnityAddMsgIfSpecified(msg);
|
||||
UNITY_FAIL_AND_BAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold,
|
||||
const UNITY_DOUBLE actual,
|
||||
|
||||
Reference in New Issue
Block a user