| OLD | NEW |
| 1 /******************************************************************** | 1 /******************************************************************** |
| 2 * COPYRIGHT: | 2 * COPYRIGHT: |
| 3 * Copyright (c) 1997-2013, International Business Machines Corporation and | 3 * Copyright (c) 1997-2014, International Business Machines Corporation and |
| 4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
| 5 ******************************************************************** | 5 ******************************************************************** |
| 6 * File TMSGFMT.CPP | 6 * File TMSGFMT.CPP |
| 7 * | 7 * |
| 8 * Modification History: | 8 * Modification History: |
| 9 * | 9 * |
| 10 * Date Name Description | 10 * Date Name Description |
| 11 * 03/24/97 helena Converted from Java. | 11 * 03/24/97 helena Converted from Java. |
| 12 * 07/11/97 helena Updated to work on AIX. | 12 * 07/11/97 helena Updated to work on AIX. |
| 13 * 08/04/97 jfitz Updated to intltest | 13 * 08/04/97 jfitz Updated to intltest |
| 14 *******************************************************************/ | 14 *******************************************************************/ |
| 15 | 15 |
| 16 #include "unicode/utypes.h" | 16 #include "unicode/utypes.h" |
| 17 | 17 |
| 18 #if !UCONFIG_NO_FORMATTING | 18 #if !UCONFIG_NO_FORMATTING |
| 19 | 19 |
| 20 #include "tmsgfmt.h" | 20 #include "tmsgfmt.h" |
| 21 #include "cmemory.h" |
| 21 | 22 |
| 22 #include "unicode/format.h" | 23 #include "unicode/format.h" |
| 23 #include "unicode/decimfmt.h" | 24 #include "unicode/decimfmt.h" |
| 24 #include "unicode/localpointer.h" | 25 #include "unicode/localpointer.h" |
| 25 #include "unicode/locid.h" | 26 #include "unicode/locid.h" |
| 26 #include "unicode/msgfmt.h" | 27 #include "unicode/msgfmt.h" |
| 27 #include "unicode/numfmt.h" | 28 #include "unicode/numfmt.h" |
| 28 #include "unicode/choicfmt.h" | 29 #include "unicode/choicfmt.h" |
| 29 #include "unicode/messagepattern.h" | 30 #include "unicode/messagepattern.h" |
| 30 #include "unicode/selfmt.h" | 31 #include "unicode/selfmt.h" |
| 31 #include "unicode/gregocal.h" | 32 #include "unicode/gregocal.h" |
| 32 #include <stdio.h> | 33 #include <stdio.h> |
| 33 | 34 |
| 34 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
| 35 | |
| 36 void | 35 void |
| 37 TestMessageFormat::runIndexedTest(int32_t index, UBool exec, | 36 TestMessageFormat::runIndexedTest(int32_t index, UBool exec, |
| 38 const char* &name, char* /*par*/) { | 37 const char* &name, char* /*par*/) { |
| 39 TESTCASE_AUTO_BEGIN; | 38 TESTCASE_AUTO_BEGIN; |
| 40 TESTCASE_AUTO(testBug1); | 39 TESTCASE_AUTO(testBug1); |
| 41 TESTCASE_AUTO(testBug2); | 40 TESTCASE_AUTO(testBug2); |
| 42 TESTCASE_AUTO(sample); | 41 TESTCASE_AUTO(sample); |
| 43 TESTCASE_AUTO(PatternTest); | 42 TESTCASE_AUTO(PatternTest); |
| 44 TESTCASE_AUTO(testStaticFormat); | 43 TESTCASE_AUTO(testStaticFormat); |
| 45 TESTCASE_AUTO(testSimpleFormat); | 44 TESTCASE_AUTO(testSimpleFormat); |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 UnicodeString tuples[] = { | 1598 UnicodeString tuples[] = { |
| 1600 // Desired output | 1599 // Desired output |
| 1601 // DOUBLE_OPTIONAL pattern | 1600 // DOUBLE_OPTIONAL pattern |
| 1602 // DOUBLE_REQUIRED pattern (empty=same as DOUBLE_OPTIONAL) | 1601 // DOUBLE_REQUIRED pattern (empty=same as DOUBLE_OPTIONAL) |
| 1603 "I see {many}", "I see '{many}'", "", | 1602 "I see {many}", "I see '{many}'", "", |
| 1604 "I said {'Wow!'}", "I said '{''Wow!''}'", "", | 1603 "I said {'Wow!'}", "I said '{''Wow!''}'", "", |
| 1605 "I dont know", "I dont know", "I don't know", | 1604 "I dont know", "I dont know", "I don't know", |
| 1606 "I don't know", "I don't know", "I don''t know", | 1605 "I don't know", "I don't know", "I don''t know", |
| 1607 "I don't know", "I don''t know", "I don''t know" | 1606 "I don't know", "I don''t know", "I don''t know" |
| 1608 }; | 1607 }; |
| 1609 int32_t tuples_count = LENGTHOF(tuples); | 1608 int32_t tuples_count = UPRV_LENGTHOF(tuples); |
| 1610 | 1609 |
| 1611 for (int i = 0; i < tuples_count; i += 3) { | 1610 for (int i = 0; i < tuples_count; i += 3) { |
| 1612 UnicodeString& desired = tuples[i]; | 1611 UnicodeString& desired = tuples[i]; |
| 1613 UnicodeString& ado_pattern = tuples[i + 1]; | 1612 UnicodeString& ado_pattern = tuples[i + 1]; |
| 1614 UErrorCode status = U_ZERO_ERROR; | 1613 UErrorCode status = U_ZERO_ERROR; |
| 1615 assertEquals("DOUBLE_OPTIONAL failure", | 1614 assertEquals("DOUBLE_OPTIONAL failure", |
| 1616 desired, | 1615 desired, |
| 1617 GetPatternAndSkipSyntax(ado_mp->parse(ado_pattern, NULL, stat
us))); | 1616 GetPatternAndSkipSyntax(ado_mp->parse(ado_pattern, NULL, stat
us))); |
| 1618 UnicodeString& adr_pattern = tuples[i + 2].isEmpty() ? ado_pattern : tuple
s[i + 2]; | 1617 UnicodeString& adr_pattern = tuples[i + 2].isEmpty() ? ado_pattern : tuple
s[i + 2]; |
| 1619 assertEquals("DOUBLE_REQUIRED failure", desired, | 1618 assertEquals("DOUBLE_REQUIRED failure", desired, |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1958 m2.format(args, 1, result, ignore, errorCode), TRUE); | 1957 m2.format(args, 1, result, ignore, errorCode), TRUE); |
| 1959 | 1958 |
| 1960 args[0] = (double)2.5; | 1959 args[0] = (double)2.5; |
| 1961 result.remove(); | 1960 result.remove(); |
| 1962 assertEquals("offset-decimals format(1)", "2.5 meters", | 1961 assertEquals("offset-decimals format(1)", "2.5 meters", |
| 1963 m2.format(args, 1, result, ignore, errorCode), TRUE); | 1962 m2.format(args, 1, result, ignore, errorCode), TRUE); |
| 1964 errorCode.reset(); | 1963 errorCode.reset(); |
| 1965 } | 1964 } |
| 1966 | 1965 |
| 1967 #endif /* #if !UCONFIG_NO_FORMATTING */ | 1966 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| OLD | NEW |