ICU-12701 additional porting issues.
X-SVN-Rev: 39323
This commit is contained in:
parent
da8e954004
commit
f0156c183b
@ -1267,11 +1267,11 @@ DateIntervalFormat::splitPatternInto2Part(const UnicodeString& intervalPattern)
|
|||||||
}
|
}
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
if (ch == '\'') {
|
if (ch == 0x0027 /*'*/) {
|
||||||
// Consecutive single quotes are a single quote literal,
|
// Consecutive single quotes are a single quote literal,
|
||||||
// either outside of quotes or between quotes
|
// either outside of quotes or between quotes
|
||||||
if ((i+1) < intervalPattern.length() &&
|
if ((i+1) < intervalPattern.length() &&
|
||||||
intervalPattern.charAt(i+1) == '\'') {
|
intervalPattern.charAt(i+1) == 0x0027 /*'*/) {
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
inQuote = ! inQuote;
|
inQuote = ! inQuote;
|
||||||
@ -1471,10 +1471,10 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
|
|||||||
}
|
}
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
if (ch == '\'') {
|
if (ch == 0x0027 /*'*/) {
|
||||||
// Consecutive single quotes are a single quote literal,
|
// Consecutive single quotes are a single quote literal,
|
||||||
// either outside of quotes or between quotes
|
// either outside of quotes or between quotes
|
||||||
if ((i+1) < adjustedPtn.length() && adjustedPtn.charAt(i+1) == '\'') {
|
if ((i+1) < adjustedPtn.length() && adjustedPtn.charAt(i+1) == 0x0027 /* ' */) {
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
inQuote = ! inQuote;
|
inQuote = ! inQuote;
|
||||||
|
@ -2020,7 +2020,7 @@ FormatParser::getCanonicalIndex(const UnicodeString& s, UBool strict) {
|
|||||||
}
|
}
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t bestRow = -1;
|
int32_t bestRow = -1;
|
||||||
while (dtTypes[i].patternChar != '\0') {
|
while (dtTypes[i].patternChar != 0x0000) {
|
||||||
if ( dtTypes[i].patternChar != ch ) {
|
if ( dtTypes[i].patternChar != ch ) {
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1641,7 +1641,7 @@ static void TestOverrideNumberFormat(void) {
|
|||||||
overrideFmt = NULL; // no longer valid
|
overrideFmt = NULL; // no longer valid
|
||||||
assertSuccess("udat_setNumberFormatForField()", &status);
|
assertSuccess("udat_setNumberFormatForField()", &status);
|
||||||
|
|
||||||
getter_result = udat_getNumberFormatForField(fmt, 'd');
|
getter_result = udat_getNumberFormatForField(fmt, 0x0064 /*'d'*/);
|
||||||
if(getter_result == NULL) {
|
if(getter_result == NULL) {
|
||||||
log_err("FAIL: udat_getNumberFormatForField did not return a valid pointer\n");
|
log_err("FAIL: udat_getNumberFormatForField did not return a valid pointer\n");
|
||||||
}
|
}
|
||||||
|
@ -4727,7 +4727,7 @@ void DateFormatTest::TestNumberFormatOverride() {
|
|||||||
fmt->adoptNumberFormat(fields, check_nf, status);
|
fmt->adoptNumberFormat(fields, check_nf, status);
|
||||||
assertSuccess("adoptNumberFormat check_nf", status);
|
assertSuccess("adoptNumberFormat check_nf", status);
|
||||||
|
|
||||||
const NumberFormat* get_nf = fmt->getNumberFormatForField('M');
|
const NumberFormat* get_nf = fmt->getNumberFormatForField((UChar)0x004D /*'M'*/);
|
||||||
if (get_nf != check_nf) errln("FAIL: getter and setter do not work");
|
if (get_nf != check_nf) errln("FAIL: getter and setter do not work");
|
||||||
}
|
}
|
||||||
NumberFormat* check_nf = NumberFormat::createInstance(Locale("en_US"), status);
|
NumberFormat* check_nf = NumberFormat::createInstance(Locale("en_US"), status);
|
||||||
|
@ -966,7 +966,8 @@ void DateIntervalFormatTest::testFormat() {
|
|||||||
|
|
||||||
"de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.",
|
"de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.",
|
||||||
|
|
||||||
|
/* Following is an important test, because the 'h' in 'Uhr' is interpreted as a pattern
|
||||||
|
if not escaped properly. */
|
||||||
"de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 Uhr vorm. \\u2013 2 Uhr nachm.",
|
"de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 Uhr vorm. \\u2013 2 Uhr nachm.",
|
||||||
"de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "H", "10\\u201314 Uhr",
|
"de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "H", "10\\u201314 Uhr",
|
||||||
|
|
||||||
@ -1051,17 +1052,12 @@ void DateIntervalFormatTest::expect(const char** data, int32_t data_length) {
|
|||||||
const char* pattern = data[0];
|
const char* pattern = data[0];
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
#ifdef DTIFMTTS_DEBUG
|
|
||||||
char result[1000];
|
|
||||||
char mesg[1000];
|
|
||||||
sprintf(mesg, "locale: %s\n", locName);
|
|
||||||
PRINTMESG(mesg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (i<data_length) {
|
while (i<data_length) {
|
||||||
const char* locName = data[i++];
|
const char* locName = data[i++];
|
||||||
Locale loc(locName);
|
Locale loc(locName);
|
||||||
SimpleDateFormat ref(pattern, loc, ec);
|
SimpleDateFormat ref(pattern, loc, ec);
|
||||||
|
logln( "case %d, locale: %s\n", (i-1)/5, locName);
|
||||||
|
|
||||||
if (U_FAILURE(ec)) {
|
if (U_FAILURE(ec)) {
|
||||||
dataerrln("contruct SimpleDateFormat in expect failed: %s", u_errorName(ec));
|
dataerrln("contruct SimpleDateFormat in expect failed: %s", u_errorName(ec));
|
||||||
return;
|
return;
|
||||||
@ -1069,39 +1065,25 @@ void DateIntervalFormatTest::expect(const char** data, int32_t data_length) {
|
|||||||
// 'f'
|
// 'f'
|
||||||
const char* datestr = data[i++];
|
const char* datestr = data[i++];
|
||||||
const char* datestr_2 = data[i++];
|
const char* datestr_2 = data[i++];
|
||||||
#ifdef DTIFMTTS_DEBUG
|
logln("original date: %s - %s\n", datestr, datestr_2);
|
||||||
sprintf(mesg, "original date: %s - %s\n", datestr, datestr_2);
|
|
||||||
PRINTMESG(mesg)
|
|
||||||
#endif
|
|
||||||
UDate date = ref.parse(ctou(datestr), ec);
|
UDate date = ref.parse(ctou(datestr), ec);
|
||||||
if (!assertSuccess("parse 1st data in expect", ec)) return;
|
if (!assertSuccess("parse 1st data in expect", ec)) return;
|
||||||
UDate date_2 = ref.parse(ctou(datestr_2), ec);
|
UDate date_2 = ref.parse(ctou(datestr_2), ec);
|
||||||
if (!assertSuccess("parse 2nd data in expect", ec)) return;
|
if (!assertSuccess("parse 2nd data in expect", ec)) return;
|
||||||
DateInterval dtitv(date, date_2);
|
DateInterval dtitv(date, date_2);
|
||||||
|
|
||||||
const UnicodeString& oneSkeleton = data[i++];
|
const UnicodeString& oneSkeleton(ctou(data[i++]));
|
||||||
|
|
||||||
DateIntervalFormat* dtitvfmt = DateIntervalFormat::createInstance(oneSkeleton, loc, ec);
|
DateIntervalFormat* dtitvfmt = DateIntervalFormat::createInstance(oneSkeleton, loc, ec);
|
||||||
if (!assertSuccess("createInstance(skeleton) in expect", ec)) return;
|
if (!assertSuccess("createInstance(skeleton) in expect", ec)) return;
|
||||||
FieldPosition pos(FieldPosition::DONT_CARE);
|
FieldPosition pos(FieldPosition::DONT_CARE);
|
||||||
dtitvfmt->format(&dtitv, str.remove(), pos, ec);
|
dtitvfmt->format(&dtitv, str.remove(), pos, ec);
|
||||||
if (!assertSuccess("format in expect", ec)) return;
|
if (!assertSuccess("format in expect", ec)) return;
|
||||||
assertEquals((UnicodeString)"\"" + locName + "\\" + oneSkeleton + "\\" + datestr + "\\" + datestr_2 + "\"", ctou(data[i++]), str);
|
assertEquals((UnicodeString)"\"" + locName + "\\" + oneSkeleton + "\\" + ctou(datestr) + "\\" + ctou(datestr_2) + "\"", ctou(data[i++]), str);
|
||||||
|
|
||||||
|
logln("interval date:" + str + "\"" + locName + "\", "
|
||||||
|
+ "\"" + datestr + "\", "
|
||||||
#ifdef DTIFMTTS_DEBUG
|
+ "\"" + datestr_2 + "\", " + oneSkeleton);
|
||||||
str.extract(0, str.length(), result, "UTF-8");
|
|
||||||
sprintf(mesg, "interval date: %s\n", result);
|
|
||||||
std::cout << "//";
|
|
||||||
PRINTMESG(mesg)
|
|
||||||
std::cout << "\"" << locName << "\", "
|
|
||||||
<< "\"" << datestr << "\", "
|
|
||||||
<< "\"" << datestr_2 << "\", ";
|
|
||||||
printUnicodeString(oneSkeleton);
|
|
||||||
printUnicodeString(str);
|
|
||||||
std::cout << "\n\n";
|
|
||||||
#endif
|
|
||||||
delete dtitvfmt;
|
delete dtitvfmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1707,12 +1707,14 @@ void MeasureFormatTest::TestGram() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MeasureFormatTest::TestCurrencies() {
|
void MeasureFormatTest::TestCurrencies() {
|
||||||
UChar USD[] = {'U', 'S', 'D', 0};
|
UChar USD[4];
|
||||||
|
u_uastrcpy(USD, "USD");
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
CurrencyAmount USD_1(1.0, USD, status);
|
CurrencyAmount USD_1(1.0, USD, status);
|
||||||
|
assertEquals("Currency Code", USD, USD_1.getISOCurrency());
|
||||||
CurrencyAmount USD_2(2.0, USD, status);
|
CurrencyAmount USD_2(2.0, USD, status);
|
||||||
CurrencyAmount USD_NEG_1(-1.0, USD, status);
|
CurrencyAmount USD_NEG_1(-1.0, USD, status);
|
||||||
if (!assertSuccess("Error creating measures", status)) {
|
if (!assertSuccess("Error creating currencies", status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Locale en("en");
|
Locale en("en");
|
||||||
@ -2081,7 +2083,7 @@ void MeasureFormatTest::verifyFormatWithPrefix(
|
|||||||
if (!assertSuccess("Error formatting", status)) {
|
if (!assertSuccess("Error formatting", status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assertEquals(description, UnicodeString(expected).unescape(), result);
|
assertEquals(description, ctou(expected), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeasureFormatTest::verifyFormat(
|
void MeasureFormatTest::verifyFormat(
|
||||||
|
@ -172,6 +172,7 @@ void StringTest::runIndexedTest(int32_t index, UBool exec, const char *&name, ch
|
|||||||
TESTCASE_AUTO(TestStringByteSink);
|
TESTCASE_AUTO(TestStringByteSink);
|
||||||
TESTCASE_AUTO(TestCharString);
|
TESTCASE_AUTO(TestCharString);
|
||||||
TESTCASE_AUTO(TestCStr);
|
TESTCASE_AUTO(TestCStr);
|
||||||
|
TESTCASE_AUTO(Testctou);
|
||||||
TESTCASE_AUTO_END;
|
TESTCASE_AUTO_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,3 +546,11 @@ StringTest::TestCStr() {
|
|||||||
errln("%s:%d CStr(s)() failed. Expected \"%s\", got \"%s\"", __FILE__, __LINE__, cs, CStr(us)());
|
errln("%s:%d CStr(s)() failed. Expected \"%s\", got \"%s\"", __FILE__, __LINE__, cs, CStr(us)());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StringTest::Testctou() {
|
||||||
|
const char *cs = "Fa\\u0127mu";
|
||||||
|
UnicodeString u = ctou(cs);
|
||||||
|
assertEquals("Testing unescape@0", (int32_t)0x0046, u.charAt(0));
|
||||||
|
assertEquals("Testing unescape@2", (int32_t)295, u.charAt(2));
|
||||||
|
}
|
||||||
|
@ -48,6 +48,7 @@ private:
|
|||||||
void TestSTLCompatibility();
|
void TestSTLCompatibility();
|
||||||
void TestCharString();
|
void TestCharString();
|
||||||
void TestCStr();
|
void TestCStr();
|
||||||
|
void Testctou();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user