提交 48033506 编写于 作者: J jsalling

No print masking of integers, bounds on hex printing

上级 6695e9e9
......@@ -52,21 +52,6 @@ static const char UnityStrResultsIgnored[] = " Ignored ";
static const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
/* compiler-generic print formatting masks */
static const UNITY_UINT UnitySizeMask[] =
{
255u, /* 0xFF */
65535u, /* 0xFFFF */
65535u,
4294967295u, /* 0xFFFFFFFF */
4294967295u,
4294967295u,
4294967295u
#ifdef UNITY_SUPPORT_64
,0xFFFFFFFFFFFFFFFF
#endif
};
/*-----------------------------------------------
* Pretty Printers & Test Result Output Handlers
*-----------------------------------------------*/
......@@ -155,13 +140,13 @@ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T
}
else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
{
UnityPrintNumberUnsigned( (UNITY_UINT)number & UnitySizeMask[((UNITY_UINT)style & (UNITY_UINT)0x0F) - 1] );
UnityPrintNumberUnsigned((UNITY_UINT)number);
}
else
{
UNITY_OUTPUT_CHAR('0');
UNITY_OUTPUT_CHAR('x');
UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0x000F) << 1));
UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2));
}
}
......@@ -203,19 +188,21 @@ void UnityPrintNumberUnsigned(const UNITY_UINT number)
/*-----------------------------------------------*/
void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print)
{
UNITY_UINT nibble;
int nibble;
char nibbles = nibbles_to_print;
if ((unsigned)nibbles > 2 * sizeof number) nibbles = 2 * sizeof number;
while (nibbles > 0)
{
nibble = (number >> (--nibbles << 2)) & 0x0000000F;
nibbles--;
nibble = (number >> (nibbles * 4)) & 0x0F;
if (nibble <= 9)
{
UNITY_OUTPUT_CHAR((char)('0' + nibble));
UNITY_OUTPUT_CHAR('0' + nibble);
}
else
{
UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
UNITY_OUTPUT_CHAR('A' - 10 + nibble);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册