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

Function UnityAssertEqualStringArray

src/unity.c:1670–1750  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1668
1669/*-----------------------------------------------*/
1670void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected,
1671 const char** actual,
1672 const UNITY_UINT32 num_elements,
1673 const char* msg,
1674 const UNITY_LINE_TYPE lineNumber,
1675 const UNITY_FLAGS_T flags)
1676{
1677 UNITY_UINT32 i = 0;
1678 UNITY_UINT32 j = 0;
1679 const char* expd = NULL;
1680 const char* act = NULL;
1681
1682 RETURN_IF_FAIL_OR_IGNORE;
1683
1684 /* if no elements, it's an error */
1685 if (num_elements == 0)
1686 {
1687#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
1688 UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
1689#else
1690 UnityPrintPointlessAndBail();
1691#endif
1692 }
1693
1694 if ((const void*)expected == (const void*)actual)
1695 {
1696 return; /* Both are NULL or same pointer */
1697 }
1698
1699 if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
1700 {
1701 UNITY_FAIL_AND_BAIL;
1702 }
1703
1704 if (flags != UNITY_ARRAY_TO_ARRAY)
1705 {
1706 expd = (const char*)expected;
1707 }
1708
1709 do
1710 {
1711 act = actual[j];
1712 if (flags == UNITY_ARRAY_TO_ARRAY)
1713 {
1714 expd = ((const char* const*)expected)[j];
1715 }
1716
1717 /* if both pointers not null compare the strings */
1718 if (expd && act)
1719 {
1720 for (i = 0; expd[i] || act[i]; i++)
1721 {
1722 if (expd[i] != act[i])
1723 {
1724 Unity.CurrentTestFailed = 1;
1725 break;
1726 }
1727 }

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