Left: | ||
Right: |
OLD | NEW |
---|---|
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html | 2 // License & terms of use: http://www.unicode.org/copyright.html |
3 /******************************************************************** | 3 /******************************************************************** |
4 * COPYRIGHT: | 4 * COPYRIGHT: |
5 * Copyright (c) 1997-2016, International Business Machines Corporation and | 5 * Copyright (c) 1997-2016, International Business Machines Corporation and |
6 * others. All Rights Reserved. | 6 * others. All Rights Reserved. |
7 ********************************************************************/ | 7 ********************************************************************/ |
8 /* Modification History: | 8 /* Modification History: |
9 * Date Name Description | 9 * Date Name Description |
10 * 07/15/99 helena Ported to HPUX 10/11 CC. | 10 * 07/15/99 helena Ported to HPUX 10/11 CC. |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 TESTCASE_AUTO(TestBenchmark); | 592 TESTCASE_AUTO(TestBenchmark); |
593 TESTCASE_AUTO(TestCtorApplyPatternDifference); | 593 TESTCASE_AUTO(TestCtorApplyPatternDifference); |
594 TESTCASE_AUTO(TestFractionalDigitsForCurrency); | 594 TESTCASE_AUTO(TestFractionalDigitsForCurrency); |
595 TESTCASE_AUTO(TestFormatCurrencyPlural); | 595 TESTCASE_AUTO(TestFormatCurrencyPlural); |
596 TESTCASE_AUTO(Test11868); | 596 TESTCASE_AUTO(Test11868); |
597 TESTCASE_AUTO(Test10727_RoundingZero); | 597 TESTCASE_AUTO(Test10727_RoundingZero); |
598 TESTCASE_AUTO(Test11376_getAndSetPositivePrefix); | 598 TESTCASE_AUTO(Test11376_getAndSetPositivePrefix); |
599 TESTCASE_AUTO(Test11475_signRecognition); | 599 TESTCASE_AUTO(Test11475_signRecognition); |
600 TESTCASE_AUTO(Test11640_getAffixes); | 600 TESTCASE_AUTO(Test11640_getAffixes); |
601 TESTCASE_AUTO(Test11649_toPatternWithMultiCurrency); | 601 TESTCASE_AUTO(Test11649_toPatternWithMultiCurrency); |
602 TESTCASE_AUTO(Test13327_numberingSystemBufferOverflow); | |
602 TESTCASE_AUTO_END; | 603 TESTCASE_AUTO_END; |
603 } | 604 } |
604 | 605 |
605 // ------------------------------------- | 606 // ------------------------------------- |
606 | 607 |
607 // Test API (increase code coverage) | 608 // Test API (increase code coverage) |
608 void | 609 void |
609 NumberFormatTest::TestAPI(void) | 610 NumberFormatTest::TestAPI(void) |
610 { | 611 { |
611 logln("Test API"); | 612 logln("Test API"); |
(...skipping 8116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8728 DecimalFormat fmt2(topattern, status); | 8729 DecimalFormat fmt2(topattern, status); |
8729 if (!assertSuccess("", status)) { | 8730 if (!assertSuccess("", status)) { |
8730 return; | 8731 return; |
8731 } | 8732 } |
8732 fmt2.setCurrency(USD); | 8733 fmt2.setCurrency(USD); |
8733 ···· | 8734 ···· |
8734 appendTo.remove(); | 8735 appendTo.remove(); |
8735 assertEquals("", "US dollars 12.34", fmt2.format(12.34, appendTo)); | 8736 assertEquals("", "US dollars 12.34", fmt2.format(12.34, appendTo)); |
8736 } | 8737 } |
8737 | 8738 |
8739 void NumberFormatTest::Test13327_numberingSystemBufferOverflow() { | |
8740 UErrorCode status; | |
8741 for (int runId = 0; runId < 2; runId++) { | |
andy.heninger
2017/09/08 17:52:09
It would be a little simpler to do something like
markus.icu
2017/09/11 23:05:00
I agree, but I don't care strongly.
sffc
2017/09/28 00:54:38
Since there was a thread about range-based for loo
| |
8742 // Construct a locale string with a very long "numbers" value. | |
8743 // The first time, make the value length exactly equal to ULOC_KEYWORDS_ CAPACITY. | |
8744 // The second time, make it exceed ULOC_KEYWORDS_CAPACITY. | |
8745 int extraLength = (runId == 0) ? 0 : 5; | |
8746 char localeId[ULOC_KEYWORDS_CAPACITY + 20] = "en@numbers="; | |
8747 for (int i = 0; i < ULOC_KEYWORDS_CAPACITY + extraLength; i++) { | |
8748 localeId[i + 11] = 'x'; | |
markus.icu
2017/09/11 23:05:00
This +11 looks a little fragile.
I would
char
sffc
2017/09/28 00:54:38
I changed it to use CharString like Andy suggested
| |
8749 } | |
8750 localeId[ULOC_KEYWORDS_CAPACITY + extraLength + 11] = 0; | |
8751 Locale locale(localeId); | |
8752 NumberingSystem* ns = NumberingSystem::createInstance(locale, status); | |
8753 assertFalse("Should not be null", ns == nullptr); | |
8754 assertEquals("Should create with no error", U_ZERO_ERROR, status); | |
markus.icu
2017/09/11 23:05:00
We have an assertSuccess(), don't we?
sffc
2017/09/28 00:54:38
Done.
| |
8755 } | |
8756 } | |
8757 | |
8738 | 8758 |
8739 void NumberFormatTest::verifyFieldPositionIterator( | 8759 void NumberFormatTest::verifyFieldPositionIterator( |
8740 NumberFormatTest_Attributes *expected, FieldPositionIterator &iter) { | 8760 NumberFormatTest_Attributes *expected, FieldPositionIterator &iter) { |
8741 int32_t idx = 0; | 8761 int32_t idx = 0; |
8742 FieldPosition fp; | 8762 FieldPosition fp; |
8743 while (iter.next(fp)) { | 8763 while (iter.next(fp)) { |
8744 if (expected[idx].spos == -1) { | 8764 if (expected[idx].spos == -1) { |
8745 errln("Iterator should have ended. got %d", fp.getField()); | 8765 errln("Iterator should have ended. got %d", fp.getField()); |
8746 return; | 8766 return; |
8747 } | 8767 } |
(...skipping 22 matching lines...) Expand all Loading... | |
8770 errln((UnicodeString) | 8790 errln((UnicodeString) |
8771 "Fail: Construct DecimalFormat formatter"); | 8791 "Fail: Construct DecimalFormat formatter"); |
8772 } | 8792 } |
8773 | 8793 |
8774 ParsePosition ppos(0); | 8794 ParsePosition ppos(0); |
8775 fmt.parseCurrency("53.45", ppos); // NPE thrown here in ICU4J. | 8795 fmt.parseCurrency("53.45", ppos); // NPE thrown here in ICU4J. |
8776 assertEquals("Issue11735 ppos", 0, ppos.getIndex()); | 8796 assertEquals("Issue11735 ppos", 0, ppos.getIndex()); |
8777 } | 8797 } |
8778 | 8798 |
8779 #endif /* #if !UCONFIG_NO_FORMATTING */ | 8799 #endif /* #if !UCONFIG_NO_FORMATTING */ |
OLD | NEW |