MCPcopy Create free account
hub / github.com/DaveGamble/cJSON / UnityAssertNumbersWithin

Function UnityAssertNumbersWithin

tests/unity/src/unity.c:965–1001  ·  view source on GitHub ↗

-----------------------------------------------*/

Source from the content-addressed store, hash-verified

963
964/*-----------------------------------------------*/
965void UnityAssertNumbersWithin(const UNITY_UINT delta,
966 const UNITY_INT expected,
967 const UNITY_INT actual,
968 const char* msg,
969 const UNITY_LINE_TYPE lineNumber,
970 const UNITY_DISPLAY_STYLE_T style)
971{
972 RETURN_IF_FAIL_OR_IGNORE;
973
974 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
975 {
976 if (actual > expected)
977 Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta);
978 else
979 Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta);
980 }
981 else
982 {
983 if ((UNITY_UINT)actual > (UNITY_UINT)expected)
984 Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta);
985 else
986 Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta);
987 }
988
989 if (Unity.CurrentTestFailed)
990 {
991 UnityTestResultsFailBegin(lineNumber);
992 UnityPrint(UnityStrDelta);
993 UnityPrintNumberByStyle((UNITY_INT)delta, style);
994 UnityPrint(UnityStrExpected);
995 UnityPrintNumberByStyle(expected, style);
996 UnityPrint(UnityStrWas);
997 UnityPrintNumberByStyle(actual, style);
998 UnityAddMsgIfSpecified(msg);
999 UNITY_FAIL_AND_BAIL;
1000 }
1001}
1002
1003/*-----------------------------------------------*/
1004void UnityAssertEqualString(const char* expected,

Callers

nothing calls this directly

Calls 4

UnityPrintFunction · 0.85
UnityPrintNumberByStyleFunction · 0.85
UnityAddMsgIfSpecifiedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…