mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-24 00:28:35 +08:00
Rename Array Check helper, always return, never longjmp
Move longjump inside caller, to functions returning 'void' This single function needed to change to allow optional setjmp.h
This commit is contained in:
45
src/unity.c
45
src/unity.c
@ -480,32 +480,32 @@ static void UnityPrintExpectedAndActualStringsLen(const char* expected, const ch
|
|||||||
* Assertion & Control Helpers
|
* Assertion & Control Helpers
|
||||||
*-----------------------------------------------*/
|
*-----------------------------------------------*/
|
||||||
|
|
||||||
static int UnityCheckArraysForNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
|
static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected,
|
||||||
|
UNITY_INTERNAL_PTR actual,
|
||||||
|
const UNITY_LINE_TYPE lineNumber,
|
||||||
|
const char* msg)
|
||||||
{
|
{
|
||||||
/* return true if they are both NULL */
|
if (expected == actual) return 0; /* Both are NULL or same pointer */
|
||||||
if ((expected == NULL) && (actual == NULL))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* throw error if just expected is NULL */
|
/* print and return true if just expected is NULL */
|
||||||
if (expected == NULL)
|
if (expected == NULL)
|
||||||
{
|
{
|
||||||
UnityTestResultsFailBegin(lineNumber);
|
UnityTestResultsFailBegin(lineNumber);
|
||||||
UnityPrint(UnityStrNullPointerForExpected);
|
UnityPrint(UnityStrNullPointerForExpected);
|
||||||
UnityAddMsgIfSpecified(msg);
|
UnityAddMsgIfSpecified(msg);
|
||||||
UNITY_FAIL_AND_BAIL;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* throw error if just actual is NULL */
|
/* print and return true if just actual is NULL */
|
||||||
if (actual == NULL)
|
if (actual == NULL)
|
||||||
{
|
{
|
||||||
UnityTestResultsFailBegin(lineNumber);
|
UnityTestResultsFailBegin(lineNumber);
|
||||||
UnityPrint(UnityStrNullPointerForActual);
|
UnityPrint(UnityStrNullPointerForActual);
|
||||||
UnityAddMsgIfSpecified(msg);
|
UnityAddMsgIfSpecified(msg);
|
||||||
UNITY_FAIL_AND_BAIL;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return false if neither is NULL */
|
return 0; /* return false if neither is NULL */
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------
|
/*-----------------------------------------------
|
||||||
@ -578,8 +578,9 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
|||||||
UnityPrintPointlessAndBail();
|
UnityPrintPointlessAndBail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
|
if (expected == actual) return; /* Both are NULL or same pointer */
|
||||||
return;
|
if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
|
||||||
|
UNITY_FAIL_AND_BAIL;
|
||||||
|
|
||||||
while (elements--)
|
while (elements--)
|
||||||
{
|
{
|
||||||
@ -685,8 +686,9 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected,
|
|||||||
UnityPrintPointlessAndBail();
|
UnityPrintPointlessAndBail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
|
if (expected == actual) return; /* Both are NULL or same pointer */
|
||||||
return;
|
if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
|
||||||
|
UNITY_FAIL_AND_BAIL;
|
||||||
|
|
||||||
while (elements--)
|
while (elements--)
|
||||||
{
|
{
|
||||||
@ -810,8 +812,9 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expecte
|
|||||||
UnityPrintPointlessAndBail();
|
UnityPrintPointlessAndBail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
|
if (expected == actual) return; /* Both are NULL or same pointer */
|
||||||
return;
|
if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
|
||||||
|
UNITY_FAIL_AND_BAIL;
|
||||||
|
|
||||||
while (elements--)
|
while (elements--)
|
||||||
{
|
{
|
||||||
@ -1047,8 +1050,9 @@ void UnityAssertEqualStringArray( const char** expected,
|
|||||||
UnityPrintPointlessAndBail();
|
UnityPrintPointlessAndBail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
|
if (expected == actual) return; /* Both are NULL or same pointer */
|
||||||
return;
|
if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg))
|
||||||
|
UNITY_FAIL_AND_BAIL;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1107,8 +1111,9 @@ void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
|
|||||||
UnityPrintPointlessAndBail();
|
UnityPrintPointlessAndBail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnityCheckArraysForNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg) == 1)
|
if (expected == actual) return; /* Both are NULL or same pointer */
|
||||||
return;
|
if (UnityIsOneArrayNull(expected, actual, lineNumber, msg))
|
||||||
|
UNITY_FAIL_AND_BAIL;
|
||||||
|
|
||||||
while (elements--)
|
while (elements--)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user