MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / UnityAssertEqualMemory

Function UnityAssertEqualMemory

tests/unity/src/unity.c:1162–1217  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1160
1161/*-----------------------------------------------*/
1162void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
1163 UNITY_INTERNAL_PTR actual,
1164 const UNITY_UINT32 length,
1165 const UNITY_UINT32 num_elements,
1166 const char* msg,
1167 const UNITY_LINE_TYPE lineNumber,
1168 const UNITY_FLAGS_T flags)
1169{
1170 UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
1171 UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
1172 UNITY_UINT32 elements = num_elements;
1173 UNITY_UINT32 bytes;
1174
1175 RETURN_IF_FAIL_OR_IGNORE;
1176
1177 if ((elements == 0) || (length == 0))
1178 {
1179 UnityPrintPointlessAndBail();
1180 }
1181
1182 if (expected == actual) return; /* Both are NULL or same pointer */
1183 if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
1184 UNITY_FAIL_AND_BAIL;
1185
1186 while (elements--)
1187 {
1188 bytes = length;
1189 while (bytes--)
1190 {
1191 if (*ptr_exp != *ptr_act)
1192 {
1193 UnityTestResultsFailBegin(lineNumber);
1194 UnityPrint(UnityStrMemory);
1195 if (num_elements > 1)
1196 {
1197 UnityPrint(UnityStrElement);
1198 UnityPrintNumberUnsigned(num_elements - elements - 1);
1199 }
1200 UnityPrint(UnityStrByte);
1201 UnityPrintNumberUnsigned(length - bytes - 1);
1202 UnityPrint(UnityStrExpected);
1203 UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
1204 UnityPrint(UnityStrWas);
1205 UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
1206 UnityAddMsgIfSpecified(msg);
1207 UNITY_FAIL_AND_BAIL;
1208 }
1209 ptr_exp++;
1210 ptr_act++;
1211 }
1212 if (flags == UNITY_ARRAY_TO_VAL)
1213 {
1214 ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
1215 }
1216 }
1217}
1218
1219/*-----------------------------------------------*/

Callers

nothing calls this directly

Calls 6

UnityIsOneArrayNullFunction · 0.85
UnityPrintFunction · 0.85
UnityPrintNumberUnsignedFunction · 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…