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

Function UnityAssertEqualStringArray

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

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

Source from the content-addressed store, hash-verified

1081
1082/*-----------------------------------------------*/
1083void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected,
1084 const char** actual,
1085 const UNITY_UINT32 num_elements,
1086 const char* msg,
1087 const UNITY_LINE_TYPE lineNumber,
1088 const UNITY_FLAGS_T flags)
1089{
1090 UNITY_UINT32 i = 0;
1091 UNITY_UINT32 j = 0;
1092 const char* expd = NULL;
1093 const char* act = NULL;
1094
1095 RETURN_IF_FAIL_OR_IGNORE;
1096
1097 /* if no elements, it's an error */
1098 if (num_elements == 0)
1099 {
1100 UnityPrintPointlessAndBail();
1101 }
1102
1103 if ((const void*)expected == (const void*)actual)
1104 {
1105 return; /* Both are NULL or same pointer */
1106 }
1107
1108 if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
1109 {
1110 UNITY_FAIL_AND_BAIL;
1111 }
1112
1113 if (flags != UNITY_ARRAY_TO_ARRAY)
1114 {
1115 expd = (const char*)expected;
1116 }
1117
1118 do
1119 {
1120 act = actual[j];
1121 if (flags == UNITY_ARRAY_TO_ARRAY)
1122 {
1123 expd = ((const char* const*)expected)[j];
1124 }
1125
1126 /* if both pointers not null compare the strings */
1127 if (expd && act)
1128 {
1129 for (i = 0; expd[i] || act[i]; i++)
1130 {
1131 if (expd[i] != act[i])
1132 {
1133 Unity.CurrentTestFailed = 1;
1134 break;
1135 }
1136 }
1137 }
1138 else
1139 { /* handle case of one pointers being null (if both null, test should pass) */
1140 if (expd != act)

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…