mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-07-26 13:15:00 +08:00
Added support for %b (bits / binary), %f (float) and %g (double).
This commit is contained in:
44
src/unity.c
44
src/unity.c
@ -164,29 +164,47 @@ void UnityPrintFormatted(const char* format, ... )
|
|||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
const UNITY_INT number = va_arg(va, UNITY_INT);
|
const int number = va_arg(va, int);
|
||||||
UnityPrintNumber(number);
|
UnityPrintNumber((UNITY_INT)number);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifndef UNITY_EXCLUDE_FLOAT_PRINT
|
||||||
|
case 'f':
|
||||||
|
case 'g':
|
||||||
|
{
|
||||||
|
const double number = va_arg(va, double);
|
||||||
|
UnityPrintFloat((UNITY_DOUBLE)number);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
const UNITY_UINT number = va_arg(va, UNITY_UINT);
|
const unsigned int number = va_arg(va, unsigned int);
|
||||||
UnityPrintNumberUnsigned(number);
|
UnityPrintNumberUnsigned((UNITY_UINT)number);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'b':
|
||||||
|
{
|
||||||
|
const unsigned int number = va_arg(va, unsigned int);
|
||||||
|
const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1;
|
||||||
|
UNITY_OUTPUT_CHAR('0');
|
||||||
|
UNITY_OUTPUT_CHAR('b');
|
||||||
|
UnityPrintMask(mask, (UNITY_UINT)number);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
case 'p':
|
case 'p':
|
||||||
{
|
{
|
||||||
const UNITY_UINT number = va_arg(va, UNITY_UINT);
|
const unsigned int number = va_arg(va, unsigned int);
|
||||||
UNITY_OUTPUT_CHAR('0');
|
UNITY_OUTPUT_CHAR('0');
|
||||||
UNITY_OUTPUT_CHAR('x');
|
UNITY_OUTPUT_CHAR('x');
|
||||||
UnityPrintNumberHex(number, 8);
|
UnityPrintNumberHex((UNITY_UINT)number, 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
const UNITY_INT ch = va_arg(va, UNITY_INT);
|
const int ch = va_arg(va, int);
|
||||||
UnityPrintChar((const char *)&ch);
|
UnityPrintChar((const char *)&ch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -196,9 +214,17 @@ void UnityPrintFormatted(const char* format, ... )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '%':
|
case '%':
|
||||||
|
{
|
||||||
|
UnityPrintChar(pch);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UnityPrintChar(pch);
|
{
|
||||||
break;
|
/* print the unknown character */
|
||||||
|
UNITY_OUTPUT_CHAR('%');
|
||||||
|
UnityPrintChar(pch);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@
|
|||||||
typedef UNITY_INT32 UNITY_INT;
|
typedef UNITY_INT32 UNITY_INT;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* 64-bit Support */
|
/* 64-bit Support */
|
||||||
#if (UNITY_LONG_WIDTH == 32)
|
#if (UNITY_LONG_WIDTH == 32)
|
||||||
typedef unsigned long long UNITY_UINT64;
|
typedef unsigned long long UNITY_UINT64;
|
||||||
typedef signed long long UNITY_INT64;
|
typedef signed long long UNITY_INT64;
|
||||||
|
Reference in New Issue
Block a user