mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-12-16 20:51:17 +08:00
Merge branch 'master' into more-float
This commit is contained in:
33
src/unity.c
33
src/unity.c
@@ -19,9 +19,9 @@ void UNITY_OUTPUT_CHAR(int);
|
||||
#endif
|
||||
|
||||
/* Helpful macros for us to use here in Assert functions */
|
||||
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); }
|
||||
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); }
|
||||
#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT()
|
||||
#define UNITY_FAIL_AND_BAIL do { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
|
||||
#define UNITY_IGNORE_AND_BAIL do { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
|
||||
#define RETURN_IF_FAIL_OR_IGNORE do { if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) { TEST_ABORT(); } } while (0)
|
||||
|
||||
struct UNITY_STORAGE_T Unity;
|
||||
|
||||
@@ -369,10 +369,12 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
|
||||
}
|
||||
else
|
||||
{
|
||||
UNITY_INT32 n_int = 0, n;
|
||||
int exponent = 0;
|
||||
int decimals, digits;
|
||||
char buf[16] = {0};
|
||||
UNITY_INT32 n_int = 0;
|
||||
UNITY_INT32 n;
|
||||
int exponent = 0;
|
||||
int decimals;
|
||||
int digits;
|
||||
char buf[16] = {0};
|
||||
|
||||
/*
|
||||
* Scale up or down by powers of 10. To minimize rounding error,
|
||||
@@ -450,9 +452,14 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
|
||||
buf[digits++] = (char)('0' + n % 10);
|
||||
n /= 10;
|
||||
}
|
||||
|
||||
/* print out buffer (backwards) */
|
||||
while (digits > 0)
|
||||
{
|
||||
if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); }
|
||||
if (digits == decimals)
|
||||
{
|
||||
UNITY_OUTPUT_CHAR('.');
|
||||
}
|
||||
UNITY_OUTPUT_CHAR(buf[--digits]);
|
||||
}
|
||||
|
||||
@@ -765,11 +772,12 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
|
||||
}
|
||||
|
||||
#define UnityPrintPointlessAndBail() \
|
||||
{ \
|
||||
do { \
|
||||
UnityTestResultsFailBegin(lineNumber); \
|
||||
UnityPrint(UnityStrPointless); \
|
||||
UnityAddMsgIfSpecified(msg); \
|
||||
UNITY_FAIL_AND_BAIL; }
|
||||
UNITY_FAIL_AND_BAIL; \
|
||||
} while (0)
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
||||
@@ -884,11 +892,12 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
||||
|
||||
#ifndef UNITY_EXCLUDE_FLOAT_PRINT
|
||||
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
|
||||
{ \
|
||||
do { \
|
||||
UnityPrint(UnityStrExpected); \
|
||||
UnityPrintFloat(expected); \
|
||||
UnityPrint(UnityStrWas); \
|
||||
UnityPrintFloat(actual); }
|
||||
UnityPrintFloat(actual); \
|
||||
} while (0)
|
||||
#else
|
||||
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
|
||||
UnityPrint(UnityStrDelta)
|
||||
|
||||
Reference in New Issue
Block a user