MCPcopy Index your code
hub / github.com/ThrowTheSwitch/Unity / UnityAssertGreaterOrLessFloat

Function UnityAssertGreaterOrLessFloat

src/unity.c:1053–1083  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1051
1052/*-----------------------------------------------*/
1053void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold,
1054 const UNITY_FLOAT actual,
1055 const UNITY_COMPARISON_T compare,
1056 const char* msg,
1057 const UNITY_LINE_TYPE lineNumber)
1058{
1059 int failed;
1060
1061 RETURN_IF_FAIL_OR_IGNORE;
1062
1063 failed = 0;
1064
1065 /* Checking for "not success" rather than failure to get the right result for NaN */
1066 if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; }
1067 if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; }
1068
1069 if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; }
1070
1071 if (failed)
1072 {
1073 UnityTestResultsFailBegin(lineNumber);
1074 UnityPrint(UnityStrExpected);
1075 UnityPrintFloat(actual);
1076 if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); }
1077 if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); }
1078 if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); }
1079 UnityPrintFloat(threshold);
1080 UnityAddMsgIfSpecified(msg);
1081 UNITY_FAIL_AND_BAIL;
1082 }
1083}
1084
1085/*-----------------------------------------------*/
1086void UnityAssertFloatSpecial(const UNITY_FLOAT actual,

Callers

nothing calls this directly

Calls 5

UnityFloatsWithinFunction · 0.85
UnityPrintFunction · 0.85
UnityPrintFloatFunction · 0.85
UnityAddMsgIfSpecifiedFunction · 0.85

Tested by

no test coverage detected