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

Function UnityAssertEqualMemory

src/unity.c:1753–1822  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1751
1752/*-----------------------------------------------*/
1753void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected,
1754 UNITY_INTERNAL_PTR actual,
1755 const UNITY_UINT32 length,
1756 const UNITY_UINT32 num_elements,
1757 const char* msg,
1758 const UNITY_LINE_TYPE lineNumber,
1759 const UNITY_FLAGS_T flags)
1760{
1761 UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
1762 UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
1763 UNITY_UINT32 elements = num_elements;
1764 UNITY_UINT32 bytes;
1765
1766 RETURN_IF_FAIL_OR_IGNORE;
1767
1768 if (elements == 0)
1769 {
1770#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY
1771 UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg);
1772#else
1773 UnityPrintPointlessAndBail();
1774#endif
1775 }
1776 if (length == 0)
1777 {
1778 UnityPrintPointlessAndBail();
1779 }
1780
1781 if (expected == actual)
1782 {
1783 return; /* Both are NULL or same pointer */
1784 }
1785
1786 if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
1787 {
1788 UNITY_FAIL_AND_BAIL;
1789 }
1790
1791 while (elements--)
1792 {
1793 bytes = length;
1794 while (bytes--)
1795 {
1796 if (*ptr_exp != *ptr_act)
1797 {
1798 UnityTestResultsFailBegin(lineNumber);
1799 UnityPrint(UnityStrMemory);
1800 if (num_elements > 1)
1801 {
1802 UnityPrint(UnityStrElement);
1803 UnityPrintNumberUnsigned(num_elements - elements - 1);
1804 }
1805 UnityPrint(UnityStrByte);
1806 UnityPrintNumberUnsigned(length - bytes - 1);
1807 UnityPrint(UnityStrExpected);
1808 UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
1809 UnityPrint(UnityStrWas);
1810 UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);

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