ICU-837 Test and implement the plus sign in the printf format.
X-SVN-Rev: 8310
This commit is contained in:
parent
018b9a1fea
commit
1c24ef9b24
@ -233,9 +233,10 @@ static const u_sprintf_info g_u_sprintf_infos[108] = {
|
||||
|
||||
/* buffer size for formatting */
|
||||
#define USPRINTF_BUFFER_SIZE 1024
|
||||
#define USPRINTF_EXP_BUFFER_SIZE 8
|
||||
#define USPRINTF_SYMBOL_BUFFER_SIZE 8
|
||||
|
||||
static UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* (null) */
|
||||
static UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */
|
||||
static UChar gSpaceStr[] = {0x20, 0}; /* " " */
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
u_sprintf(UChar *buffer,
|
||||
@ -412,6 +413,37 @@ u_sprintf_pad_and_justify(u_localized_string *output,
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Sets the sign of a format based on u_sprintf_spec_info */
|
||||
/* TODO: Is setting the prefix symbol to a positive sign a good idea in all locales? */
|
||||
static void
|
||||
u_sprintf_set_sign(UNumberFormat *format,
|
||||
const u_sprintf_spec_info *info,
|
||||
UErrorCode *status)
|
||||
{
|
||||
if(info->fShowSign) {
|
||||
if (info->fSpace) {
|
||||
/* Setting UNUM_PLUS_SIGN_SYMBOL affects the exponent too. */
|
||||
/* unum_setSymbol(format, UNUM_PLUS_SIGN_SYMBOL, gSpaceStr, 1, &status); */
|
||||
unum_setTextAttribute(format, UNUM_POSITIVE_PREFIX, gSpaceStr, 1, status);
|
||||
}
|
||||
else {
|
||||
UChar plusSymbol[USPRINTF_SYMBOL_BUFFER_SIZE];
|
||||
int32_t symbolLen;
|
||||
|
||||
symbolLen = unum_getSymbol(format,
|
||||
UNUM_PLUS_SIGN_SYMBOL,
|
||||
plusSymbol,
|
||||
sizeof(plusSymbol)/sizeof(*plusSymbol),
|
||||
status);
|
||||
unum_setTextAttribute(format,
|
||||
UNUM_POSITIVE_PREFIX,
|
||||
plusSymbol,
|
||||
symbolLen,
|
||||
status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* handle a '%' */
|
||||
|
||||
int32_t
|
||||
@ -522,16 +554,16 @@ u_sprintf_integer_handler(u_localized_string *output,
|
||||
format = u_locbund_getNumberFormat(output->fBundle);
|
||||
}
|
||||
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
u_sprintf_set_sign(format, info, &status);
|
||||
}
|
||||
|
||||
/* format the number */
|
||||
unum_format(format, num, result, USPRINTF_BUFFER_SIZE, 0, &status);
|
||||
|
||||
/* restore the number format */
|
||||
if(minDigits != -1)
|
||||
if(minDigits != -1) {
|
||||
unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, minDigits);
|
||||
}
|
||||
|
||||
return u_sprintf_pad_and_justify(output, info, result, u_strlen(result));
|
||||
}
|
||||
@ -679,10 +711,7 @@ u_sprintf_double_handler(u_localized_string *output,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_sprintf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, USPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -749,7 +778,6 @@ u_sprintf_pointer_handler(u_localized_string *output,
|
||||
return u_sprintf_pad_and_justify(output, info, result, len);
|
||||
}
|
||||
|
||||
|
||||
int32_t
|
||||
u_sprintf_scientific_handler(u_localized_string *output,
|
||||
const u_sprintf_spec_info *info,
|
||||
@ -761,9 +789,9 @@ u_sprintf_scientific_handler(u_localized_string *output,
|
||||
int32_t minDecimalDigits;
|
||||
int32_t maxDecimalDigits;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UChar srcExpBuf[USPRINTF_EXP_BUFFER_SIZE];
|
||||
UChar srcExpBuf[USPRINTF_SYMBOL_BUFFER_SIZE];
|
||||
int32_t srcLen, expLen;
|
||||
UChar expBuf[USPRINTF_EXP_BUFFER_SIZE];
|
||||
UChar expBuf[USPRINTF_SYMBOL_BUFFER_SIZE];
|
||||
|
||||
|
||||
/* mask off any necessary bits */
|
||||
@ -837,10 +865,7 @@ u_sprintf_scientific_handler(u_localized_string *output,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_sprintf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, USPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -965,10 +990,7 @@ u_sprintf_percent_handler(u_localized_string *output,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_sprintf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, USPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -1039,10 +1061,7 @@ u_sprintf_currency_handler(u_localized_string *output,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_sprintf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, USPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -1221,10 +1240,7 @@ u_sprintf_spellout_handler(u_localized_string *output,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_sprintf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, USPRINTF_BUFFER_SIZE, 0, &status);
|
||||
|
@ -144,6 +144,7 @@ u_sprintf_parse_spec (const UChar *fmt,
|
||||
|
||||
/* use space if no sign present */
|
||||
case FLAG_SPACE:
|
||||
info->fShowSign = TRUE;
|
||||
info->fSpace = TRUE;
|
||||
break;
|
||||
|
||||
|
@ -231,9 +231,10 @@ static const u_printf_info g_u_printf_infos[108] = {
|
||||
|
||||
/* buffer size for formatting */
|
||||
#define UFPRINTF_BUFFER_SIZE 1024
|
||||
#define UFPRINTF_EXP_BUFFER_SIZE 8
|
||||
#define UFPRINTF_SYMBOL_BUFFER_SIZE 8
|
||||
|
||||
static UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* (null) */
|
||||
static UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */
|
||||
static UChar gSpaceStr[] = {0x20, 0}; /* " " */
|
||||
|
||||
int32_t
|
||||
u_fprintf( UFILE *f,
|
||||
@ -322,6 +323,37 @@ u_printf_pad_and_justify(UFILE *stream,
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Sets the sign of a format based on u_sprintf_spec_info */
|
||||
/* TODO: Is setting the prefix symbol to a positive sign a good idea in all locales? */
|
||||
static void
|
||||
u_printf_set_sign(UNumberFormat *format,
|
||||
const u_printf_spec_info *info,
|
||||
UErrorCode *status)
|
||||
{
|
||||
if(info->fShowSign) {
|
||||
if (info->fSpace) {
|
||||
/* Setting UNUM_PLUS_SIGN_SYMBOL affects the exponent too. */
|
||||
/* unum_setSymbol(format, UNUM_PLUS_SIGN_SYMBOL, gSpaceStr, 1, &status); */
|
||||
unum_setTextAttribute(format, UNUM_POSITIVE_PREFIX, gSpaceStr, 1, status);
|
||||
}
|
||||
else {
|
||||
UChar plusSymbol[UFPRINTF_SYMBOL_BUFFER_SIZE];
|
||||
int32_t symbolLen;
|
||||
|
||||
symbolLen = unum_getSymbol(format,
|
||||
UNUM_PLUS_SIGN_SYMBOL,
|
||||
plusSymbol,
|
||||
sizeof(plusSymbol)/sizeof(*plusSymbol),
|
||||
status);
|
||||
unum_setTextAttribute(format,
|
||||
UNUM_POSITIVE_PREFIX,
|
||||
plusSymbol,
|
||||
symbolLen,
|
||||
status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* handle a '%' */
|
||||
|
||||
int32_t
|
||||
@ -429,8 +461,7 @@ u_printf_integer_handler(UFILE *stream,
|
||||
format = u_locbund_getNumberFormat(stream->fBundle);
|
||||
}
|
||||
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
u_printf_set_sign(format, info, &status);
|
||||
}
|
||||
|
||||
/* format the number */
|
||||
@ -586,10 +617,7 @@ u_printf_double_handler(UFILE *stream,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_printf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, UFPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -668,9 +696,9 @@ u_printf_scientific_handler(UFILE *stream,
|
||||
int32_t minDecimalDigits;
|
||||
int32_t maxDecimalDigits;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UChar srcExpBuf[UFPRINTF_EXP_BUFFER_SIZE];
|
||||
UChar srcExpBuf[UFPRINTF_SYMBOL_BUFFER_SIZE];
|
||||
int32_t srcLen, expLen;
|
||||
UChar expBuf[UFPRINTF_EXP_BUFFER_SIZE];
|
||||
UChar expBuf[UFPRINTF_SYMBOL_BUFFER_SIZE];
|
||||
|
||||
|
||||
/* mask off any necessary bits */
|
||||
@ -744,10 +772,7 @@ u_printf_scientific_handler(UFILE *stream,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_printf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, UFPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -872,10 +897,7 @@ u_printf_percent_handler(UFILE *stream,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_printf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, UFPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -946,10 +968,7 @@ u_printf_currency_handler(UFILE *stream,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_printf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, UFPRINTF_BUFFER_SIZE, 0, &status);
|
||||
@ -1128,10 +1147,7 @@ u_printf_spellout_handler(UFILE *stream,
|
||||
}
|
||||
|
||||
/* set whether to show the sign */
|
||||
if(info->fShowSign) {
|
||||
/* set whether to show the sign*/
|
||||
/* {sfb} TODO */
|
||||
}
|
||||
u_printf_set_sign(format, info, &status);
|
||||
|
||||
/* format the number */
|
||||
unum_formatDouble(format, num, result, UFPRINTF_BUFFER_SIZE, 0, &status);
|
||||
|
@ -145,6 +145,7 @@ u_printf_parse_spec (const UChar *fmt,
|
||||
|
||||
/* use space if no sign present */
|
||||
case FLAG_SPACE:
|
||||
info->fShowSign = TRUE;
|
||||
info->fSpace = TRUE;
|
||||
break;
|
||||
|
||||
|
@ -487,17 +487,23 @@ static void TestFprintfFormat() {
|
||||
TestFPrintFormat("%8c", 0x65, "%8c", 0x65);
|
||||
TestFPrintFormat("%-8c", 0x65, "%-8c", 0x65);
|
||||
|
||||
TestFPrintFormat("%8K", (UChar)0x65, "%8c", 0x65);
|
||||
TestFPrintFormat("%-8K", (UChar)0x65, "%-8c", 0x65);
|
||||
TestFPrintFormat("%8K", (UChar)0x65, "%8c", (char)0x65);
|
||||
TestFPrintFormat("%-8K", (UChar)0x65, "%-8c", (char)0x65);
|
||||
|
||||
TestFPrintFormat("%8f", 1.23456789, "%8f", 1.23456789);
|
||||
TestFPrintFormat("%-8f", 1.23456789, "%-8f", 1.23456789);
|
||||
TestFPrintFormat("%10f", 1.23456789, "%10f", 1.23456789);
|
||||
TestFPrintFormat("%-10f", 1.23456789, "%-10f", 1.23456789);
|
||||
TestFPrintFormat("%10f", 123.456789, "%10f", 123.456789);
|
||||
TestFPrintFormat("%-10f", 123.456789, "%-10f", 123.456789);
|
||||
|
||||
TestFPrintFormat("%8e", 1.23456789, "%8e", 1.23456789);
|
||||
TestFPrintFormat("%-8e", 1.23456789, "%-8e", 1.23456789);
|
||||
TestFPrintFormat("%10e", 1.23456789, "%10e", 1.23456789);
|
||||
TestFPrintFormat("%-10e", 1.23456789, "%-10e", 1.23456789);
|
||||
TestFPrintFormat("%10e", 123.456789, "%10e", 123.456789);
|
||||
TestFPrintFormat("%-10e", 123.456789, "%-10e", 123.456789);
|
||||
|
||||
TestFPrintFormat("%8g", 1.23456789, "%8g", 1.23456789);
|
||||
TestFPrintFormat("%-8g", 1.23456789, "%-8g", 1.23456789);
|
||||
TestFPrintFormat("%10g", 1.23456789, "%10g", 1.23456789);
|
||||
TestFPrintFormat("%-10g", 1.23456789, "%-10g", 1.23456789);
|
||||
TestFPrintFormat("%10g", 123.456789, "%10g", 123.456789);
|
||||
TestFPrintFormat("%-10g", 123.456789, "%-10g", 123.456789);
|
||||
|
||||
TestFPrintFormat("%8x", 123456, "%8x", 123456);
|
||||
TestFPrintFormat("%-8x", 123456, "%-8x", 123456);
|
||||
@ -519,48 +525,59 @@ static void TestFprintfFormat() {
|
||||
|
||||
TestFPrintFormat("%8d", 123456, "%8d", 123456);
|
||||
TestFPrintFormat("%-8d", 123456, "%-8d", 123456);
|
||||
TestFPrintFormat("% d", 123456, "% d", 123456);
|
||||
TestFPrintFormat("% d", -123456, "% d", -123456);
|
||||
|
||||
TestFPrintFormat("%8i", 123456, "%8i", 123456);
|
||||
TestFPrintFormat("%-8i", 123456, "%-8i", 123456);
|
||||
|
||||
TestFPrintFormat("% d", 123456, "% d", 123456);
|
||||
TestFPrintFormat("% d", -123456, "% d", -123456);
|
||||
|
||||
log_verbose("Get really crazy with the formatting.\n");
|
||||
|
||||
TestFPrintFormat("%-+ #12x", 123, "%-+ #12x", 123);
|
||||
TestFPrintFormat("%-+ #12x", -123, "%-+ #12x", -123);
|
||||
TestFPrintFormat("%+ #12x", 123, "%+ #12x", 123);
|
||||
TestFPrintFormat("%+ #12x", -123, "%+ #12x", -123);
|
||||
TestFPrintFormat("%-#12x", 123, "%-#12x", 123);
|
||||
TestFPrintFormat("%-#12x", -123, "%-#12x", -123);
|
||||
TestFPrintFormat("%#12x", 123, "%#12x", 123);
|
||||
TestFPrintFormat("%#12x", -123, "%#12x", -123);
|
||||
|
||||
TestFPrintFormat("%-+ 12d", 123, "%-+ 12d", 123);
|
||||
TestFPrintFormat("%-+ 12d", -123, "%-+ 12d", -123);
|
||||
TestFPrintFormat("%+ 12d", 123, "%+ 12d", 123);
|
||||
TestFPrintFormat("%+ 12d", -123, "%+ 12d", -123);
|
||||
TestFPrintFormat("%+12d", 123, "%+12d", 123);
|
||||
TestFPrintFormat("%+12d", -123, "%+12d", -123);
|
||||
TestFPrintFormat("%- 12d", 123, "%- 12d", 123);
|
||||
TestFPrintFormat("%-+12d", 123, "%-+12d", 123);
|
||||
TestFPrintFormat("%-+12d", -123, "%-+12d", -123);
|
||||
TestFPrintFormat("%- 12d", 123, "%- 12d", 123);
|
||||
TestFPrintFormat("%- 12d", -123, "%- 12d", -123);
|
||||
TestFPrintFormat("% 12d", 123, "% 12d", 123);
|
||||
TestFPrintFormat("% 12d", -123, "% 12d", -123);
|
||||
TestFPrintFormat("%+12d", 123, "%+12d", 123);
|
||||
TestFPrintFormat("%+12d", -123, "%+12d", -123);
|
||||
TestFPrintFormat("% 12d", 123, "% 12d", 123);
|
||||
TestFPrintFormat("% 12d", -123, "% 12d", -123);
|
||||
TestFPrintFormat("%12d", 123, "%12d", 123);
|
||||
TestFPrintFormat("%12d", -123, "%12d", -123);
|
||||
|
||||
TestFPrintFormat("%-+ 12.1e", 1.234, "%-+ 12.1e", 1.234);
|
||||
TestFPrintFormat("%-+ 12.1e", -1.234, "%-+ 12.1e", -1.234);
|
||||
TestFPrintFormat("%+ 12.1e", 1.234, "%+ 12.1e", 1.234);
|
||||
TestFPrintFormat("%+ 12.1e", -1.234, "%+ 12.1e", -1.234);
|
||||
TestFPrintFormat("%+12.1e", 1.234, "%+12.1e", 1.234);
|
||||
TestFPrintFormat("%+12.1e", -1.234, "%+12.1e", -1.234);
|
||||
TestFPrintFormat("% 12.1e", 1.234, "% 12.1e", 1.234);
|
||||
TestFPrintFormat("% 12.1e", -1.234, "% 12.1e", -1.234);
|
||||
TestFPrintFormat("%-+12.1e", 1.234, "%-+12.1e", 1.234);
|
||||
TestFPrintFormat("%-+12.1e", -1.234, "%-+12.1e", -1.234);
|
||||
TestFPrintFormat("%- 12.1e", 1.234, "%- 12.1e", 1.234);
|
||||
TestFPrintFormat("%- 12.1e", -1.234, "%- 12.1e", -1.234);
|
||||
TestFPrintFormat("%+12.1e", 1.234, "%+12.1e", 1.234);
|
||||
TestFPrintFormat("%+12.1e", -1.234, "%+12.1e", -1.234);
|
||||
TestFPrintFormat("% 12.1e", 1.234, "% 12.1e", 1.234);
|
||||
TestFPrintFormat("% 12.1e", -1.234, "% 12.1e", -1.234);
|
||||
TestFPrintFormat("%12.1e", 1.234, "%12.1e", 1.234);
|
||||
TestFPrintFormat("%12.1e", -1.234, "%12.1e", -1.234);
|
||||
TestFPrintFormat("%.2e", 1.234, "%.2e", 1.234);
|
||||
TestFPrintFormat("%.2e", -1.234, "%.2e", -1.234);
|
||||
TestFPrintFormat("%3e", 1.234, "%3e", 1.234);
|
||||
TestFPrintFormat("%3e", -1.234, "%3e", -1.234);
|
||||
|
||||
TestFPrintFormat("%-+ 12.1f", 1.234, "%-+ 12.1f", 1.234);
|
||||
TestFPrintFormat("%-+ 12.1f", -1.234, "%-+ 12.1f", -1.234);
|
||||
TestFPrintFormat("%+ 12.1f", 1.234, "%+ 12.1f", 1.234);
|
||||
TestFPrintFormat("%+ 12.1f", -1.234, "%+ 12.1f", -1.234);
|
||||
TestFPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
|
||||
TestFPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
|
||||
TestFPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
|
||||
TestFPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
|
||||
TestFPrintFormat("%-+12.1f", 1.234, "%-+12.1f", 1.234);
|
||||
TestFPrintFormat("%-+12.1f", -1.234, "%-+12.1f", -1.234);
|
||||
TestFPrintFormat("%- 12.1f", 1.234, "%- 12.1f", 1.234);
|
||||
TestFPrintFormat("%- 12.1f", -1.234, "%- 12.1f", -1.234);
|
||||
TestFPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
|
||||
TestFPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
|
||||
TestFPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
|
||||
TestFPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
|
||||
TestFPrintFormat("%12.1f", 1.234, "%12.1f", 1.234);
|
||||
TestFPrintFormat("%12.1f", -1.234, "%12.1f", -1.234);
|
||||
TestFPrintFormat("%.2f", 1.234, "%.2f", 1.234);
|
||||
TestFPrintFormat("%.2f", -1.234, "%.2f", -1.234);
|
||||
TestFPrintFormat("%3f", 1.234, "%3f", 1.234);
|
||||
TestFPrintFormat("%3f", -1.234, "%3f", -1.234);
|
||||
}
|
||||
|
||||
#undef TestFPrintFormat
|
||||
@ -823,17 +840,23 @@ static void TestSprintfFormat() {
|
||||
TestSPrintFormat("%8c", 0x65, "%8c", 0x65);
|
||||
TestSPrintFormat("%-8c", 0x65, "%-8c", 0x65);
|
||||
|
||||
TestSPrintFormat("%8K", (UChar)0x65, "%8c", 0x65);
|
||||
TestSPrintFormat("%-8K", (UChar)0x65, "%-8c", 0x65);
|
||||
TestSPrintFormat("%8K", (UChar)0x65, "%8c", (char)0x65);
|
||||
TestSPrintFormat("%-8K", (UChar)0x65, "%-8c", (char)0x65);
|
||||
|
||||
TestSPrintFormat("%8f", 1.23456789, "%8f", 1.23456789);
|
||||
TestSPrintFormat("%-8f", 1.23456789, "%-8f", 1.23456789);
|
||||
TestSPrintFormat("%10f", 1.23456789, "%10f", 1.23456789);
|
||||
TestSPrintFormat("%-10f", 1.23456789, "%-10f", 1.23456789);
|
||||
TestSPrintFormat("%10f", 123.456789, "%10f", 123.456789);
|
||||
TestSPrintFormat("%-10f", 123.456789, "%-10f", 123.456789);
|
||||
|
||||
TestSPrintFormat("%8e", 1.23456789, "%8e", 1.23456789);
|
||||
TestSPrintFormat("%-8e", 1.23456789, "%-8e", 1.23456789);
|
||||
TestSPrintFormat("%10e", 1.23456789, "%10e", 1.23456789);
|
||||
TestSPrintFormat("%-10e", 1.23456789, "%-10e", 1.23456789);
|
||||
TestSPrintFormat("%10e", 123.456789, "%10e", 123.456789);
|
||||
TestSPrintFormat("%-10e", 123.456789, "%-10e", 123.456789);
|
||||
|
||||
TestSPrintFormat("%8g", 1.23456789, "%8g", 1.23456789);
|
||||
TestSPrintFormat("%-8g", 1.23456789, "%-8g", 1.23456789);
|
||||
TestSPrintFormat("%10g", 1.23456789, "%10g", 1.23456789);
|
||||
TestSPrintFormat("%-10g", 1.23456789, "%-10g", 1.23456789);
|
||||
TestSPrintFormat("%10g", 123.456789, "%10g", 123.456789);
|
||||
TestSPrintFormat("%-10g", 123.456789, "%-10g", 123.456789);
|
||||
|
||||
TestSPrintFormat("%8x", 123456, "%8x", 123456);
|
||||
TestSPrintFormat("%-8x", 123456, "%-8x", 123456);
|
||||
@ -855,48 +878,59 @@ static void TestSprintfFormat() {
|
||||
|
||||
TestSPrintFormat("%8d", 123456, "%8d", 123456);
|
||||
TestSPrintFormat("%-8d", 123456, "%-8d", 123456);
|
||||
TestSPrintFormat("% d", 123456, "% d", 123456);
|
||||
TestSPrintFormat("% d", -123456, "% d", -123456);
|
||||
|
||||
TestSPrintFormat("%8i", 123456, "%8i", 123456);
|
||||
TestSPrintFormat("%-8i", 123456, "%-8i", 123456);
|
||||
|
||||
TestSPrintFormat("% d", 123456, "% d", 123456);
|
||||
TestSPrintFormat("% d", -123456, "% d", -123456);
|
||||
|
||||
log_verbose("Get really crazy with the formatting.\n");
|
||||
|
||||
TestSPrintFormat("%-+ #12x", 123, "%-+ #12x", 123);
|
||||
TestSPrintFormat("%-+ #12x", -123, "%-+ #12x", -123);
|
||||
TestSPrintFormat("%+ #12x", 123, "%+ #12x", 123);
|
||||
TestSPrintFormat("%+ #12x", -123, "%+ #12x", -123);
|
||||
TestSPrintFormat("%-#12x", 123, "%-#12x", 123);
|
||||
TestSPrintFormat("%-#12x", -123, "%-#12x", -123);
|
||||
TestSPrintFormat("%#12x", 123, "%#12x", 123);
|
||||
TestSPrintFormat("%#12x", -123, "%#12x", -123);
|
||||
|
||||
TestSPrintFormat("%-+ 12d", 123, "%-+ 12d", 123);
|
||||
TestSPrintFormat("%-+ 12d", -123, "%-+ 12d", -123);
|
||||
TestSPrintFormat("%+ 12d", 123, "%+ 12d", 123);
|
||||
TestSPrintFormat("%+ 12d", -123, "%+ 12d", -123);
|
||||
TestSPrintFormat("%+12d", 123, "%+12d", 123);
|
||||
TestSPrintFormat("%+12d", -123, "%+12d", -123);
|
||||
TestSPrintFormat("%- 12d", 123, "%- 12d", 123);
|
||||
TestSPrintFormat("%-+12d", 123, "%-+12d", 123);
|
||||
TestSPrintFormat("%-+12d", -123, "%-+12d", -123);
|
||||
TestSPrintFormat("%- 12d", 123, "%- 12d", 123);
|
||||
TestSPrintFormat("%- 12d", -123, "%- 12d", -123);
|
||||
TestSPrintFormat("% 12d", 123, "% 12d", 123);
|
||||
TestSPrintFormat("% 12d", -123, "% 12d", -123);
|
||||
TestSPrintFormat("%+12d", 123, "%+12d", 123);
|
||||
TestSPrintFormat("%+12d", -123, "%+12d", -123);
|
||||
TestSPrintFormat("% 12d", 123, "% 12d", 123);
|
||||
TestSPrintFormat("% 12d", -123, "% 12d", -123);
|
||||
TestSPrintFormat("%12d", 123, "%12d", 123);
|
||||
TestSPrintFormat("%12d", -123, "%12d", -123);
|
||||
|
||||
TestSPrintFormat("%-+ 12.1e", 1.234, "%-+ 12.1e", 1.234);
|
||||
TestSPrintFormat("%-+ 12.1e", -1.234, "%-+ 12.1e", -1.234);
|
||||
TestSPrintFormat("%+ 12.1e", 1.234, "%+ 12.1e", 1.234);
|
||||
TestSPrintFormat("%+ 12.1e", -1.234, "%+ 12.1e", -1.234);
|
||||
TestSPrintFormat("%+12.1e", 1.234, "%+12.1e", 1.234);
|
||||
TestSPrintFormat("%+12.1e", -1.234, "%+12.1e", -1.234);
|
||||
TestSPrintFormat("% 12.1e", 1.234, "% 12.1e", 1.234);
|
||||
TestSPrintFormat("% 12.1e", -1.234, "% 12.1e", -1.234);
|
||||
TestSPrintFormat("%-+12.1e", 1.234, "%-+12.1e", 1.234);
|
||||
TestSPrintFormat("%-+12.1e", -1.234, "%-+12.1e", -1.234);
|
||||
TestSPrintFormat("%- 12.1e", 1.234, "%- 12.1e", 1.234);
|
||||
TestSPrintFormat("%- 12.1e", -1.234, "%- 12.1e", -1.234);
|
||||
TestSPrintFormat("%+12.1e", 1.234, "%+12.1e", 1.234);
|
||||
TestSPrintFormat("%+12.1e", -1.234, "%+12.1e", -1.234);
|
||||
TestSPrintFormat("% 12.1e", 1.234, "% 12.1e", 1.234);
|
||||
TestSPrintFormat("% 12.1e", -1.234, "% 12.1e", -1.234);
|
||||
TestSPrintFormat("%12.1e", 1.234, "%12.1e", 1.234);
|
||||
TestSPrintFormat("%12.1e", -1.234, "%12.1e", -1.234);
|
||||
TestSPrintFormat("%.2e", 1.234, "%.2e", 1.234);
|
||||
TestSPrintFormat("%.2e", -1.234, "%.2e", -1.234);
|
||||
TestSPrintFormat("%3e", 1.234, "%3e", 1.234);
|
||||
TestSPrintFormat("%3e", -1.234, "%3e", -1.234);
|
||||
|
||||
TestSPrintFormat("%-+ 12.1f", 1.234, "%-+ 12.1f", 1.234);
|
||||
TestSPrintFormat("%-+ 12.1f", -1.234, "%-+ 12.1f", -1.234);
|
||||
TestSPrintFormat("%+ 12.1f", 1.234, "%+ 12.1f", 1.234);
|
||||
TestSPrintFormat("%+ 12.1f", -1.234, "%+ 12.1f", -1.234);
|
||||
TestSPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
|
||||
TestSPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
|
||||
TestSPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
|
||||
TestSPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
|
||||
TestSPrintFormat("%-+12.1f", 1.234, "%-+12.1f", 1.234);
|
||||
TestSPrintFormat("%-+12.1f", -1.234, "%-+12.1f", -1.234);
|
||||
TestSPrintFormat("%- 12.1f", 1.234, "%- 12.1f", 1.234);
|
||||
TestSPrintFormat("%- 12.1f", -1.234, "%- 12.1f", -1.234);
|
||||
TestSPrintFormat("%+12.1f", 1.234, "%+12.1f", 1.234);
|
||||
TestSPrintFormat("%+12.1f", -1.234, "%+12.1f", -1.234);
|
||||
TestSPrintFormat("% 12.1f", 1.234, "% 12.1f", 1.234);
|
||||
TestSPrintFormat("% 12.1f", -1.234, "% 12.1f", -1.234);
|
||||
TestSPrintFormat("%12.1f", 1.234, "%12.1f", 1.234);
|
||||
TestSPrintFormat("%12.1f", -1.234, "%12.1f", -1.234);
|
||||
TestSPrintFormat("%.2f", 1.234, "%.2f", 1.234);
|
||||
TestSPrintFormat("%.2f", -1.234, "%.2f", -1.234);
|
||||
TestSPrintFormat("%3f", 1.234, "%3f", 1.234);
|
||||
TestSPrintFormat("%3f", -1.234, "%3f", -1.234);
|
||||
}
|
||||
|
||||
#undef TestSPrintFormat
|
||||
|
Loading…
Reference in New Issue
Block a user