/***********************************************************************
- * Copyright (c) 1997-2012, International Business Machines Corporation
+ * Copyright (c) 1997-2014, International Business Machines Corporation
* and others. All Rights Reserved.
***********************************************************************/
CASE(62,Test9109);
CASE(63,Test9780);
CASE(64,Test9677);
+ CASE(65,Test10361);
default: name = ""; break;
}
UErrorCode status = U_ZERO_ERROR;
char loc[256]={0};
int len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
+ (void)len; // Suppress set but not used warning.
formatter = NumberFormat::createInstance(Locale(loc), status);
if(U_FAILURE(status)) {
dataerrln("Error creating DecimalFormat: %s", u_errorName(status));
UnicodeString tempString;
/* user error :
String expectedDefault = "-5.789,987";
- String expectedCurrency = "5.789,98 DEM";
+ String expectedCurrency = "5.789,98 DM";
String expectedPercent = "-578.998%";
*/
UnicodeString expectedDefault("-5.789,988");
- UnicodeString expectedCurrency("5.789,99\\u00A0DEM");
+ UnicodeString expectedCurrency("5.789,99\\u00A0DM");
UnicodeString expectedPercent("-578.999\\u00A0%");
expectedCurrency = expectedCurrency.unescape();
// Error Checking / Reporting macros
//
//---------------------------------------------------------------------------
-#define TEST_CHECK_STATUS(status) \
- if (U_FAILURE(status)) {\
- errln("File %s, Line %d. status=%s\n", __FILE__, __LINE__, u_errorName(status));\
- return;\
- }
+#define TEST_CHECK_STATUS(status) { \
+ if (U_FAILURE(status)) { \
+ if (status == U_MISSING_RESOURCE_ERROR) { \
+ dataerrln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
+ } else { \
+ errln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
+ } return; \
+ }}
#define TEST_ASSERT(expr) \
if ((expr)==FALSE) {\
}
}
+void NumberFormatRegressionTest::Test10361(void) {
+ // DecimalFormat/NumberFormat were artificially limiting the number of digits,
+ // preventing formatting of big decimals.
+ UErrorCode status = U_ZERO_ERROR;
+ DecimalFormatSymbols symbols(Locale::getEnglish(), status);
+ LocalPointer<DecimalFormat> df(new DecimalFormat("###.##", symbols, status), status);
+ TEST_CHECK_STATUS(status);
+
+ // Create a decimal number with a million digits.
+ const int32_t NUMSIZE=1000000;
+ char *num = new char[NUMSIZE];
+ for (int32_t i=0; i<NUMSIZE; i++) {
+ num[i] = '0' + (i+1) % 10;
+ }
+ num[NUMSIZE-3] = '.';
+ num[NUMSIZE-1] = 0;
+
+ UnicodeString s;
+ Formattable fmtable;
+ fmtable.setDecimalNumber(num, status);
+ TEST_CHECK_STATUS(status);
+
+ FieldPosition pos(UNUM_DECIMAL_SEPARATOR_FIELD);
+ df->format(fmtable, s, pos, status);
+ TEST_CHECK_STATUS(status);
+ TEST_ASSERT(999999 == s.length());
+ TEST_ASSERT(999997 == pos.getBeginIndex());
+ TEST_ASSERT(999998 == pos.getEndIndex());
+
+ UnicodeString expected(num, -1, US_INV);
+ TEST_ASSERT(expected == s);
+ delete [] num;
+}
#endif /* #if !UCONFIG_NO_FORMATTING */