OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * Copyright (c) 2008-2014, International Business Machines Corporation and | 2 * Copyright (c) 2008-2014, International Business Machines Corporation and |
3 * others. All Rights Reserved. | 3 * others. All Rights Reserved. |
4 ********************************************************************/ | 4 ********************************************************************/ |
5 | 5 |
6 #include "unicode/utypes.h" | 6 #include "unicode/utypes.h" |
7 | 7 |
8 #if !UCONFIG_NO_FORMATTING | 8 #if !UCONFIG_NO_FORMATTING |
9 | 9 |
10 #include "unicode/decimfmt.h" | 10 #include "unicode/decimfmt.h" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 nf->setMinimumFractionDigits(i); | 434 nf->setMinimumFractionDigits(i); |
435 nf->setMaximumFractionDigits(i); | 435 nf->setMaximumFractionDigits(i); |
436 nf->setRoundingMode(DecimalFormat::kRoundDown); | 436 nf->setRoundingMode(DecimalFormat::kRoundDown); |
437 tuf.setNumberFormat(*nf, status); | 437 tuf.setNumberFormat(*nf, status); |
438 if (U_FAILURE(status)) { | 438 if (U_FAILURE(status)) { |
439 dataerrln("setting NumberFormat failed: %s", u_errorName(status)
); | 439 dataerrln("setting NumberFormat failed: %s", u_errorName(status)
); |
440 return; | 440 return; |
441 } | 441 } |
442 UnicodeString actual; | 442 UnicodeString actual; |
443 Formattable fmt; | 443 Formattable fmt; |
444 LocalPointer<TimeUnitAmount> tamt(new TimeUnitAmount(values[j], Time
Unit::UTIMEUNIT_MINUTE, status)); | 444 LocalPointer<TimeUnitAmount> tamt( |
| 445 new TimeUnitAmount(values[j], TimeUnit::UTIMEUNIT_MINUTE, status
), status); |
445 if (U_FAILURE(status)) { | 446 if (U_FAILURE(status)) { |
446 dataerrln("generating TimeUnitAmount Object failed: %s", u_error
Name(status)); | 447 dataerrln("generating TimeUnitAmount Object failed: %s", u_error
Name(status)); |
447 return; | 448 return; |
448 } | 449 } |
449 fmt.adoptObject(tamt.orphan()); | 450 fmt.adoptObject(tamt.orphan()); |
450 tuf.format(fmt, actual, status); | 451 tuf.format(fmt, actual, status); |
451 if (U_FAILURE(status)) { | 452 if (U_FAILURE(status)) { |
452 dataerrln("Actual formatting failed: %s", u_errorName(status)); | 453 dataerrln("Actual formatting failed: %s", u_errorName(status)); |
453 return; | 454 return; |
454 } | 455 } |
455 if (expected[j][i] != actual) { | 456 if (expected[j][i] != actual) { |
456 errln("Expected " + expected[j][i] + ", got " + actual); | 457 errln("Expected " + expected[j][i] + ", got " + actual); |
457 } | 458 } |
458 } | 459 } |
459 } | 460 } |
460 | 461 |
461 // test parsing | 462 // test parsing |
462 Formattable result; | 463 Formattable result; |
463 ParsePosition pos; | 464 ParsePosition pos; |
464 UnicodeString formattedString = "1 minutes"; | 465 UnicodeString formattedString = "1 minutes"; |
465 tuf.parseObject(formattedString, result, pos); | 466 tuf.parseObject(formattedString, result, pos); |
466 if (formattedString.length() != pos.getIndex()) { | 467 if (formattedString.length() != pos.getIndex()) { |
467 errln("Expect parsing to go all the way to the end of the string."); | 468 errln("Expect parsing to go all the way to the end of the string."); |
468 } | 469 } |
469 } | 470 } |
470 | 471 |
471 #endif | 472 #endif |
OLD | NEW |