MCPcopy Create free account
hub / github.com/DaveGamble/cJSON / UnityAssertEqualIntArray

Function UnityAssertEqualIntArray

tests/unity/src/unity.c:601–675  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

599
600/*-----------------------------------------------*/
601void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
602 UNITY_INTERNAL_PTR actual,
603 const UNITY_UINT32 num_elements,
604 const char* msg,
605 const UNITY_LINE_TYPE lineNumber,
606 const UNITY_DISPLAY_STYLE_T style,
607 const UNITY_FLAGS_T flags)
608{
609 UNITY_UINT32 elements = num_elements;
610 unsigned int length = style & 0xF;
611
612 RETURN_IF_FAIL_OR_IGNORE;
613
614 if (num_elements == 0)
615 {
616 UnityPrintPointlessAndBail();
617 }
618
619 if (expected == actual) return; /* Both are NULL or same pointer */
620 if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
621 UNITY_FAIL_AND_BAIL;
622
623 while (elements--)
624 {
625 UNITY_INT expect_val;
626 UNITY_INT actual_val;
627 switch (length)
628 {
629 case 1:
630 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected;
631 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual;
632 break;
633 case 2:
634 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected;
635 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual;
636 break;
637#ifdef UNITY_SUPPORT_64
638 case 8:
639 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected;
640 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual;
641 break;
642#endif
643 default: /* length 4 bytes */
644 expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
645 actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
646 length = 4;
647 break;
648 }
649
650 if (expect_val != actual_val)
651 {
652 if (style & UNITY_DISPLAY_RANGE_UINT && length < sizeof(expect_val))
653 { /* For UINT, remove sign extension (padding 1's) from signed type casts above */
654 UNITY_INT mask = 1;
655 mask = (mask << 8 * length) - 1;
656 expect_val &= mask;
657 actual_val &= mask;
658 }

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…