mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-23 08:08:46 +08:00
Added support for %b (bits / binary), %f (float) and %g (double).
This commit is contained in:
42
src/unity.c
42
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,10 +214,18 @@ void UnityPrintFormatted(const char* format, ... )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '%':
|
case '%':
|
||||||
default:
|
{
|
||||||
UnityPrintChar(pch);
|
UnityPrintChar(pch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
/* print the unknown character */
|
||||||
|
UNITY_OUTPUT_CHAR('%');
|
||||||
|
UnityPrintChar(pch);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef UNITY_OUTPUT_COLOR
|
#ifdef UNITY_OUTPUT_COLOR
|
||||||
|
Reference in New Issue
Block a user