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

Function UnityAssertWithinFloatArray

src/unity.c:933–1010  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

931
932/*-----------------------------------------------*/
933void UnityAssertWithinFloatArray(const UNITY_FLOAT delta,
934 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected,
935 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual,
936 const UNITY_UINT32 num_elements,
937 const char* msg,
938 const UNITY_LINE_TYPE lineNumber,
939 const UNITY_FLAGS_T flags)
940{
941 UNITY_UINT32 elements = num_elements;
942 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected;
943 UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual;
944 UNITY_FLOAT in_delta = delta;
945 UNITY_FLOAT current_element_delta = delta;
946
947 RETURN_IF_FAIL_OR_IGNORE;
948
949 if (elements == 0)
950 {
951#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
952 UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
953#else
954 UnityPrintPointlessAndBail();
955#endif
956 }
957
958 if (UNITY_IS_INF(in_delta))
959 {
960 return; /* Arrays will be force equal with infinite delta */
961 }
962
963 if (UNITY_IS_NAN(in_delta))
964 {
965 /* Delta must be correct number */
966 UnityPrintPointlessAndBail();
967 }
968
969 if (expected == actual)
970 {
971 return; /* Both are NULL or same pointer */
972 }
973
974 if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
975 {
976 UNITY_FAIL_AND_BAIL;
977 }
978
979 /* fix delta sign if need */
980 if (in_delta < 0)
981 {
982 in_delta = -in_delta;
983 }
984
985 while (elements--)
986 {
987 current_element_delta = *ptr_expected * UNITY_FLOAT_PRECISION;
988
989 if (current_element_delta < 0)
990 {

Callers

nothing calls this directly

Calls 6

UnityIsOneArrayNullFunction · 0.85
UnityFloatsWithinFunction · 0.85
UnityPrintFunction · 0.85
UnityPrintNumberUnsignedFunction · 0.85
UnityAddMsgIfSpecifiedFunction · 0.85

Tested by

no test coverage detected