8164791: Update existing test cases of test/java/text/Format
Reviewed-by: okutsu, peytoia
This commit is contained in:
parent
cf73adbf80
commit
1d734cec8f
@ -50,110 +50,110 @@ public class Bug4322313 extends IntlTest {
|
||||
|
||||
Object[][] valids = {
|
||||
/* given ID offset format('z'), ('Z') index */
|
||||
{"GMT+03:04", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(9)},
|
||||
{"GMT+13:42", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(9)},
|
||||
{"GMT+00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)},
|
||||
{"GMT+1:11", new Long(-71 * mpm), "GMT+01:11", "+0111", new Integer(8)},
|
||||
{"GMT +13:42", new Long(0), "GMT", "+0000", new Integer(3)},
|
||||
{" GMT", new Long(0), "GMT", "+0000", new Integer(4)},
|
||||
{"+0304", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(5)},
|
||||
{"+1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(5)},
|
||||
{"+0000", new Long(0), "GMT+00:00", "+0000", new Integer(5)},
|
||||
{" +1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(6)},
|
||||
{"GMT+03:04", -184L * mpm, "GMT+03:04", "+0304", 9},
|
||||
{"GMT+13:42", -822L * mpm, "GMT+13:42", "+1342", 9},
|
||||
{"GMT+00:00", 0L, "GMT+00:00", "+0000", 9},
|
||||
{"GMT+1:11", -71L * mpm, "GMT+01:11", "+0111", 8},
|
||||
{"GMT +13:42", 0L, "GMT", "+0000", 3},
|
||||
{" GMT", 0L, "GMT", "+0000", 4},
|
||||
{"+0304", -184L * mpm, "GMT+03:04", "+0304", 5},
|
||||
{"+1342", -822L * mpm, "GMT+13:42", "+1342", 5},
|
||||
{"+0000", 0L, "GMT+00:00", "+0000", 5},
|
||||
{" +1342", -822L * mpm, "GMT+13:42", "+1342", 6},
|
||||
/* ISO-LATIN-1 digits */
|
||||
{"GMT+\u0030\u0031:\u0032\u0033", new Long(-83 * mpm), "GMT+01:23", "+0123", new Integer(9)},
|
||||
{"GMT+\u0030\u0031:\u0032\u0033", -83L * mpm, "GMT+01:23", "+0123", 9},
|
||||
|
||||
/* In fact, this test case is skipped because TimeZone class can't
|
||||
* recognize TimeZone IDs like "+00234" or "-00234".
|
||||
*/
|
||||
{"+00234", new Long(-23 * mpm), "GMT+00:23", "+0023", new Integer(5)},
|
||||
{"+00234", -23L * mpm, "GMT+00:23", "+0023", 5},
|
||||
|
||||
{"GMT-03:04", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(9)},
|
||||
{"GMT-13:42", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(9)},
|
||||
{"GMT-00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)},
|
||||
{"GMT-1:11", new Long(71 * mpm), "GMT-01:11", "-0111", new Integer(8)},
|
||||
{"GMT -13:42", new Long(0), "GMT", "+0000", new Integer(3)},
|
||||
{"-0304", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(5)},
|
||||
{"-1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(5)},
|
||||
{" -1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(6)},
|
||||
{"GMT-03:04", 184L * mpm, "GMT-03:04", "-0304", 9},
|
||||
{"GMT-13:42", 822L * mpm, "GMT-13:42", "-1342", 9},
|
||||
{"GMT-00:00", 0L, "GMT+00:00", "+0000", 9},
|
||||
{"GMT-1:11", 71L * mpm, "GMT-01:11", "-0111", 8},
|
||||
{"GMT -13:42", 0L, "GMT", "+0000", 3},
|
||||
{"-0304", 184L * mpm, "GMT-03:04", "-0304", 5},
|
||||
{"-1342", 822L * mpm, "GMT-13:42", "-1342", 5},
|
||||
{" -1342", 822L * mpm, "GMT-13:42", "-1342", 6},
|
||||
/* ISO-LATIN-1 digits */
|
||||
{"GMT-\u0030\u0031:\u0032\u0033", new Long(83 * mpm), "GMT-01:23", "-0123", new Integer(9)},
|
||||
{"GMT-\u0030\u0031:\u0032\u0033", 83L * mpm, "GMT-01:23", "-0123", 9},
|
||||
/* In fact, this test case is skipped because TimeZone class can't
|
||||
* recognize TimeZone IDs like "+00234" or "-00234".
|
||||
*/
|
||||
{"-00234", new Long(23 * mpm), "GMT+00:23", "-0023", new Integer(5)},
|
||||
{"-00234", 23L * mpm, "GMT+00:23", "-0023", 5},
|
||||
};
|
||||
|
||||
Object[][] invalids = {
|
||||
/* given ID error index */
|
||||
{"GMT+8", new Integer(5)},
|
||||
{"GMT+18", new Integer(6)},
|
||||
{"GMT+208", new Integer(6)},
|
||||
{"GMT+0304", new Integer(6)},
|
||||
{"GMT+42195", new Integer(5)},
|
||||
{"GMT+5:8", new Integer(7)},
|
||||
{"GMT+23:60", new Integer(8)},
|
||||
{"GMT+11:1", new Integer(8)},
|
||||
{"GMT+24:13", new Integer(5)},
|
||||
{"GMT+421:950", new Integer(5)},
|
||||
{"GMT+0a:0A", new Integer(5)},
|
||||
{"GMT+ 13:42", new Integer(4)},
|
||||
{"GMT+13 :42", new Integer(6)},
|
||||
{"GMT+13: 42", new Integer(7)},
|
||||
{"GMT+-13:42", new Integer(4)},
|
||||
{"G M T", new Integer(0)},
|
||||
{"+8", new Integer(2)},
|
||||
{"+18", new Integer(3)},
|
||||
{"+208", new Integer(4)},
|
||||
{"+2360", new Integer(4)},
|
||||
{"+2413", new Integer(2)},
|
||||
{"+42195", new Integer(2)},
|
||||
{"+0AbC", new Integer(2)},
|
||||
{"+ 1342", new Integer(1)},
|
||||
{"+-1342", new Integer(1)},
|
||||
{"1342", new Integer(0)},
|
||||
{"GMT+8", 5},
|
||||
{"GMT+18", 6},
|
||||
{"GMT+208", 6},
|
||||
{"GMT+0304", 6},
|
||||
{"GMT+42195", 5},
|
||||
{"GMT+5:8", 7},
|
||||
{"GMT+23:60", 8},
|
||||
{"GMT+11:1", 8},
|
||||
{"GMT+24:13", 5},
|
||||
{"GMT+421:950", 5},
|
||||
{"GMT+0a:0A", 5},
|
||||
{"GMT+ 13:42", 4},
|
||||
{"GMT+13 :42", 6},
|
||||
{"GMT+13: 42", 7},
|
||||
{"GMT+-13:42", 4},
|
||||
{"G M T", 0},
|
||||
{"+8", 2},
|
||||
{"+18", 3},
|
||||
{"+208", 4},
|
||||
{"+2360", 4},
|
||||
{"+2413", 2},
|
||||
{"+42195", 2},
|
||||
{"+0AbC", 2},
|
||||
{"+ 1342", 1},
|
||||
{"+-1342", 1},
|
||||
{"1342", 0},
|
||||
/* Arabic-Indic digits */
|
||||
{"GMT+\u0660\u0661:\u0662\u0663", new Integer(4)},
|
||||
{"GMT+\u0660\u0661:\u0662\u0663", 4},
|
||||
/* Extended Arabic-Indic digits */
|
||||
{"GMT+\u06f0\u06f1:\u06f2\u06f3", new Integer(4)},
|
||||
{"GMT+\u06f0\u06f1:\u06f2\u06f3", 4},
|
||||
/* Devanagari digits */
|
||||
{"GMT+\u0966\u0967:\u0968\u0969", new Integer(4)},
|
||||
{"GMT+\u0966\u0967:\u0968\u0969", 4},
|
||||
/* Fullwidth digits */
|
||||
{"GMT+\uFF10\uFF11:\uFF12\uFF13", new Integer(4)},
|
||||
{"GMT+\uFF10\uFF11:\uFF12\uFF13", 4},
|
||||
|
||||
{"GMT-8", new Integer(5)},
|
||||
{"GMT-18", new Integer(6)},
|
||||
{"GMT-208", new Integer(6)},
|
||||
{"GMT-0304", new Integer(6)},
|
||||
{"GMT-42195", new Integer(5)},
|
||||
{"GMT-5:8", new Integer(7)},
|
||||
{"GMT-23:60", new Integer(8)},
|
||||
{"GMT-11:1", new Integer(8)},
|
||||
{"GMT-24:13", new Integer(5)},
|
||||
{"GMT-421:950", new Integer(5)},
|
||||
{"GMT-0a:0A", new Integer(5)},
|
||||
{"GMT- 13:42", new Integer(4)},
|
||||
{"GMT-13 :42", new Integer(6)},
|
||||
{"GMT-13: 42", new Integer(7)},
|
||||
{"GMT-+13:42", new Integer(4)},
|
||||
{"-8", new Integer(2)},
|
||||
{"-18", new Integer(3)},
|
||||
{"-208", new Integer(4)},
|
||||
{"-2360", new Integer(4)},
|
||||
{"-2413", new Integer(2)},
|
||||
{"-42195", new Integer(2)},
|
||||
{"-0AbC", new Integer(2)},
|
||||
{"- 1342", new Integer(1)},
|
||||
{"--1342", new Integer(1)},
|
||||
{"-802", new Integer(2)},
|
||||
{"GMT-8", 5},
|
||||
{"GMT-18", 6},
|
||||
{"GMT-208", 6},
|
||||
{"GMT-0304", 6},
|
||||
{"GMT-42195", 5},
|
||||
{"GMT-5:8", 7},
|
||||
{"GMT-23:60", 8},
|
||||
{"GMT-11:1", 8},
|
||||
{"GMT-24:13", 5},
|
||||
{"GMT-421:950", 5},
|
||||
{"GMT-0a:0A", 5},
|
||||
{"GMT- 13:42", 4},
|
||||
{"GMT-13 :42", 6},
|
||||
{"GMT-13: 42", 7},
|
||||
{"GMT-+13:42", 4},
|
||||
{"-8", 2},
|
||||
{"-18", 3},
|
||||
{"-208", 4},
|
||||
{"-2360", 4},
|
||||
{"-2413", 2},
|
||||
{"-42195", 2},
|
||||
{"-0AbC", 2},
|
||||
{"- 1342", 1},
|
||||
{"--1342", 1},
|
||||
{"-802", 2},
|
||||
/* Arabic-Indic digits */
|
||||
{"GMT-\u0660\u0661:\u0662\u0663", new Integer(4)},
|
||||
{"GMT-\u0660\u0661:\u0662\u0663", 4},
|
||||
/* Extended Arabic-Indic digits */
|
||||
{"GMT-\u06f0\u06f1:\u06f2\u06f3", new Integer(4)},
|
||||
{"GMT-\u06f0\u06f1:\u06f2\u06f3", 4},
|
||||
/* Devanagari digits */
|
||||
{"GMT-\u0966\u0967:\u0968\u0969", new Integer(4)},
|
||||
{"GMT-\u0966\u0967:\u0968\u0969", 4},
|
||||
/* Fullwidth digits */
|
||||
{"GMT-\uFF10\uFF11:\uFF12\uFF13", new Integer(4)},
|
||||
{"GMT-\uFF10\uFF11:\uFF12\uFF13", 4},
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -30,6 +30,7 @@
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Bug4736959 {
|
||||
/**
|
||||
* 4736959: JSpinner won't work for AM/PM field
|
||||
|
@ -685,8 +685,8 @@ public class Bug4823811 {
|
||||
testNumberFormatFormatting(nfEG, -456, "456-", "ar_EG");
|
||||
|
||||
System.out.println("*** DecimalFormat.parse test in ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123-", new Long(-123), "ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123--", new Long(-123), "ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123-", -123L, "ar_EG");
|
||||
testNumberFormatParsing(nfEG, "123--",-123L, "ar_EG");
|
||||
testNumberFormatParsingCheckException(nfEG, "-123", 0, "ar_EG");
|
||||
|
||||
System.out.println("*** DecimalFormat.format test in en_US");
|
||||
@ -694,8 +694,8 @@ public class Bug4823811 {
|
||||
testNumberFormatFormatting(nfUS, -456, "-456", "en_US");
|
||||
|
||||
System.out.println("*** DecimalFormat.parse test in en_US");
|
||||
testNumberFormatParsing(nfUS, "123-", new Long(123), "en_US");
|
||||
testNumberFormatParsing(nfUS, "-123", new Long(-123), "en_US");
|
||||
testNumberFormatParsing(nfUS, "123-", 123L, "en_US");
|
||||
testNumberFormatParsing(nfUS, "-123",-123L, "en_US");
|
||||
testNumberFormatParsingCheckException(nfUS, "--123", 0, "en_US");
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ public class Bug4845901 {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static void testParse(SimpleDateFormat sdf, String str, int expectedHour) {
|
||||
try {
|
||||
Date parsedDate = sdf.parse(str);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -37,6 +37,7 @@ public class Bug6609750 {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
Locale.setDefault(Locale.US);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Date[] dates = {
|
||||
new Date(9-1900, Calendar.JUNE, 12),
|
||||
new Date(99-1900, Calendar.JUNE, 12),
|
||||
|
@ -66,6 +66,7 @@ public class Bug6683975 {
|
||||
System.err.println("\tth_TH: " + str_th_TH);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0);
|
||||
str_th = df_th.format(date);
|
||||
if (!expected_th[style].equals(str_th)) {
|
||||
|
@ -41,7 +41,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
}
|
||||
|
||||
public void Test4029195() {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Date today = new Date();
|
||||
|
||||
logln("today: " + today);
|
||||
@ -74,19 +74,20 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4052408() {
|
||||
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT,
|
||||
DateFormat.SHORT, Locale.US);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date date = new Date(97, Calendar.MAY, 3, 8, 55);
|
||||
String str;
|
||||
logln(str = fmt.format(date));
|
||||
|
||||
if (!str.equals("5/3/97 8:55 AM"))
|
||||
errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str);
|
||||
Hashtable expected = new Hashtable();
|
||||
expected.put(new Integer(DateFormat.MONTH_FIELD), "5");
|
||||
expected.put(new Integer(DateFormat.DATE_FIELD), "3");
|
||||
expected.put(new Integer(DateFormat.YEAR_FIELD), "97");
|
||||
expected.put(new Integer(DateFormat.HOUR1_FIELD), "8");
|
||||
expected.put(new Integer(DateFormat.MINUTE_FIELD), "55");
|
||||
expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM");
|
||||
Map<Integer,String> expected = new HashMap<>();
|
||||
expected.put(DateFormat.MONTH_FIELD, "5");
|
||||
expected.put(DateFormat.DATE_FIELD, "3");
|
||||
expected.put(DateFormat.YEAR_FIELD, "97");
|
||||
expected.put(DateFormat.HOUR1_FIELD, "8");
|
||||
expected.put(DateFormat.MINUTE_FIELD, "55");
|
||||
expected.put(DateFormat.AM_PM_FIELD, "AM");
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
String fieldNames[] = {
|
||||
@ -120,7 +121,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
", \"" + str + "\", " +
|
||||
pos.getBeginIndex() + ", " +
|
||||
pos.getEndIndex());
|
||||
String exp = (String) expected.get(new Integer(i));
|
||||
String exp = expected.get(i);
|
||||
if ((exp == null && str.length() == 0) ||
|
||||
str.equals(exp))
|
||||
logln(" ok");
|
||||
@ -135,6 +136,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
/**
|
||||
* Verify the function of the [s|g]et2DigitYearStart() API.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4056591() {
|
||||
try {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US);
|
||||
@ -255,6 +257,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
if (!ok) errln("Fail: Lenient not working");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4065240() {
|
||||
Date curDate;
|
||||
DateFormat shortdate, fulldate;
|
||||
@ -297,6 +300,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
|
||||
Currently this bug breaks MessageFormat.toPattern
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4071441() {
|
||||
DateFormat fmtA = DateFormat.getInstance();
|
||||
DateFormat fmtB = DateFormat.getInstance();
|
||||
@ -488,6 +492,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4101483() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US);
|
||||
FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d= new Date(9234567890L);
|
||||
StringBuffer buf = new StringBuffer("");
|
||||
logln(sdf.format(d, buf, fp).toString());
|
||||
@ -508,6 +513,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4103340() {
|
||||
// choose a date that is the FIRST of some month
|
||||
// and some arbitrary time
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d=new Date(97, 3, 1, 1, 1, 1);
|
||||
SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US);
|
||||
|
||||
@ -538,6 +544,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
sdf.applyPattern(pattern);
|
||||
logln("pattern: \"" + pattern + "\"");
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Object[] DATA = {
|
||||
"time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30),
|
||||
"time 10:x", new ParsePosition(0), null,
|
||||
@ -698,6 +705,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'";
|
||||
logln("pattern=" + pattern);
|
||||
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
|
||||
@SuppressWarnings("deprecation")
|
||||
String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0));
|
||||
if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) {
|
||||
errln("Fail: result=" + result);
|
||||
@ -711,6 +719,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
* 'z' at end of date format throws index exception in SimpleDateFormat
|
||||
* CANNOT REPRODUCE THIS BUG ON 1.2FCS
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4151706() {
|
||||
SimpleDateFormat fmt =
|
||||
new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US);
|
||||
@ -755,6 +764,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
* Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US
|
||||
* as "EST" or "CST", not Australian "EST" and "CST".
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4406615() {
|
||||
Locale savedLocale = Locale.getDefault();
|
||||
TimeZone savedTimeZone = TimeZone.getDefault();
|
||||
@ -823,6 +833,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
* greater than "99", are treated as literal years. So "1/2/3456"
|
||||
* becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
Object[] DATA = {
|
||||
"02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29),
|
||||
"01/23/01", new Date(2001-1900, Calendar.JANUARY, 23),
|
||||
@ -878,6 +889,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
DateFormat fmt = new SimpleDateFormat(pattern,
|
||||
DateFormatSymbols.getInstance(Locale.US));
|
||||
fmt.getCalendar().setLenient(false);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d = new Date(2000-1900, Calendar.FEBRUARY, 29);
|
||||
String s = fmt.format(d);
|
||||
logln(d + " x " + pattern + " => " + s);
|
||||
@ -957,6 +969,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void Test4253490() throws ParseException {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US);
|
||||
|
||||
@ -1026,6 +1039,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
public void Test4250359() {
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT,
|
||||
Locale.US);
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d = new Date(1999-1900, Calendar.DECEMBER, 25,
|
||||
1, 2, 3);
|
||||
String s = df.format(d);
|
||||
@ -1052,6 +1066,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
// pick up another time zone when L10N is done to that file.
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN);
|
||||
@SuppressWarnings("deprecation")
|
||||
String result = fmt.format(new Date(1999, 0, 1));
|
||||
logln("format()=>" + result);
|
||||
if (!result.endsWith("PST")) {
|
||||
|
@ -104,7 +104,7 @@ public class DateFormatRoundTripTest extends IntlTest {
|
||||
String pat = null;
|
||||
Date date = null;
|
||||
|
||||
Vector newArgs = new Vector();
|
||||
List<String> newArgs = new ArrayList<>();
|
||||
for (int i=0; i<args.length; ++i) {
|
||||
if (args[i].equals("-locale")
|
||||
&& (i+1) < args.length) {
|
||||
@ -131,13 +131,13 @@ public class DateFormatRoundTripTest extends IntlTest {
|
||||
seed = Long.parseLong(args[i+1]);
|
||||
++i;
|
||||
} else {
|
||||
newArgs.addElement(args[i]);
|
||||
newArgs.add(args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (newArgs.size() != args.length) {
|
||||
args = new String[newArgs.size()];
|
||||
newArgs.copyInto(args);
|
||||
newArgs.addAll(Arrays.asList(args));
|
||||
}
|
||||
|
||||
new DateFormatRoundTripTest(random, seed, infinite, date, pat, loc).run(args);
|
||||
@ -193,6 +193,7 @@ public class DateFormatRoundTripTest extends IntlTest {
|
||||
* Return the Date of this test case; must be called with the default
|
||||
* zone set to this TestCase's zone.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
Date getDate() {
|
||||
if (_date == null) {
|
||||
// Date constructor will work right iff we are in the target zone
|
||||
|
@ -29,6 +29,7 @@
|
||||
*/
|
||||
import java.text.DateFormatSymbols;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class DateFormatSymbolsCloneTest extends DateFormatSymbols {
|
||||
private int value;
|
||||
|
||||
|
@ -36,6 +36,7 @@ import static java.util.Calendar.*;
|
||||
public class NonGregorianFormatTest {
|
||||
static int errors;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] JAPANESE_EN = {
|
||||
{ "GGGG yyyy MMMM d", "Showa 1 December 31", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ "GGGG yyyy MMMM d", "Showa 64 January 6", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -58,6 +59,7 @@ public class NonGregorianFormatTest {
|
||||
{ "Gyy.MM.dd", "H01.01.01" },
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] BUDDHIST_EN = {
|
||||
{ "GGGG yyyy MMMM d", "B.E. 2469 December 31", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ "GGGG yyyy MMMM d", "B.E. 2532 January 6", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -71,6 +73,7 @@ public class NonGregorianFormatTest {
|
||||
|
||||
static final String FULL_DATE_FORMAT_JA = "GGGGyyyy'\u5e74'M'\u6708'd'\u65e5'";
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] JAPANESE_JA = {
|
||||
{ FULL_DATE_FORMAT_JA, "\u662d\u548c\u5143\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ FULL_DATE_FORMAT_JA, "\u662d\u548c64\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -93,6 +96,7 @@ public class NonGregorianFormatTest {
|
||||
{ "Gyy.MM.dd", "H01.01.01" },
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static final Object[][] BUDDHIST_JA = {
|
||||
{ FULL_DATE_FORMAT_JA, "\u4ecf\u66a62469\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) },
|
||||
{ FULL_DATE_FORMAT_JA, "\u4ecf\u66a62532\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) },
|
||||
@ -137,6 +141,7 @@ public class NonGregorianFormatTest {
|
||||
locale == Locale.ENGLISH ? BUDDHIST_EN : BUDDHIST_JA);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void testRoundTrip(Locale calendarLocale) {
|
||||
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL,
|
||||
DateFormat.FULL,
|
||||
|
@ -60,6 +60,7 @@ public class bug4358730 extends IntlTest {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
|
||||
for (int i = 0; i < datasize; i++) {
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d = new Date(year[i]-1900, 10, 15);
|
||||
for (int j = 0; j < nPatterns; j++) {
|
||||
sdf.applyPattern(patterns[j]);
|
||||
|
@ -98,7 +98,7 @@ public class Bug4185816Test extends IntlTest {
|
||||
final InputStream is = HexDumpReader.getStreamFromHexDump(fileName + ".txt");
|
||||
final ObjectInputStream in = new ObjectInputStream(is);
|
||||
final MessageFormat form = (MessageFormat)in.readObject();
|
||||
final Object[] testArgs = {new Long(12373), "MyDisk"};
|
||||
final Object[] testArgs = {12373L, "MyDisk"};
|
||||
final String result = form.format(testArgs);
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
|
@ -56,18 +56,19 @@ public class LargeMessageFormat {
|
||||
|
||||
private static void testFormat() {
|
||||
// construct large argument array
|
||||
@SuppressWarnings("deprecation")
|
||||
Object[] sample = {
|
||||
new Integer(0), // replace with running count below
|
||||
0, // replace with running count below
|
||||
"hello",
|
||||
new Date(89, 10, 9),
|
||||
new Integer(567890),
|
||||
new Double(1234.50)
|
||||
567890,
|
||||
1234.50
|
||||
};
|
||||
int samples = sample.length;
|
||||
Object[] arguments = new Object[REPEATS * (samples + 1)];
|
||||
for (int i = 0; i < REPEATS; i++) {
|
||||
System.arraycopy(sample, 0, arguments, i * samples, samples);
|
||||
arguments[i * samples] = new Integer(i);
|
||||
arguments[i * samples] = i;
|
||||
}
|
||||
|
||||
// construct large template
|
||||
|
@ -136,7 +136,7 @@ public class MessageRegression extends IntlTest {
|
||||
try {
|
||||
logln("Apply with pattern : " + pattern1);
|
||||
messageFormatter.applyPattern(pattern1);
|
||||
Object[] params = {new Integer(7)};
|
||||
Object[] params = {7};
|
||||
String tempBuffer = messageFormatter.format(params);
|
||||
if (!tempBuffer.equals("Impossible {1} has occurred -- status code is 7 and message is {2}."))
|
||||
errln("Tests arguments < substitution failed. Formatted text=" +
|
||||
@ -455,7 +455,7 @@ public class MessageRegression extends IntlTest {
|
||||
errln("argument0: \"" + objs[0] + "\"");
|
||||
mf.setLocale(Locale.US);
|
||||
mf.applyPattern("{0,number,#.##}, {0,number,#.#}");
|
||||
Object[] oldobjs = {new Double(3.1415)};
|
||||
Object[] oldobjs = {3.1415};
|
||||
String result = mf.format( oldobjs );
|
||||
logln("pattern: \"" + mf.toPattern() + "\"");
|
||||
logln("text for parsing: \"" + result + "\"");
|
||||
@ -481,7 +481,7 @@ public class MessageRegression extends IntlTest {
|
||||
ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
|
||||
form1.setFormat(1, fileform);
|
||||
form2.setFormat(0, fileform);
|
||||
Object[] testArgs = {new Long(12373), "MyDisk"};
|
||||
Object[] testArgs = {12373L, "MyDisk"};
|
||||
logln(form1.format(testArgs));
|
||||
logln(form2.format(testArgs));
|
||||
}
|
||||
@ -531,7 +531,7 @@ public class MessageRegression extends IntlTest {
|
||||
};
|
||||
|
||||
for (int i=0; i<3; i++) {
|
||||
String out = mf.format(new Object[]{new Integer(i)});
|
||||
String out = mf.format(new Object[]{i});
|
||||
if (SUFFIX[i] == null) {
|
||||
if (!out.equals(PREFIX[i]))
|
||||
errln("" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"");
|
||||
@ -607,8 +607,7 @@ public class MessageRegression extends IntlTest {
|
||||
*/
|
||||
public void Test4169959() {
|
||||
// This works
|
||||
logln(MessageFormat.format( "This will {0}",
|
||||
new String[]{"work"} ) );
|
||||
logln(MessageFormat.format( "This will {0}", "work"));
|
||||
|
||||
// This fails
|
||||
logln(MessageFormat.format( "This will {0}",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -52,7 +52,7 @@ public class MessageTest extends IntlTest {
|
||||
|
||||
public void TestMSGPatternTest() {
|
||||
Object[] testArgs = {
|
||||
new Double (1), new Double(3456),
|
||||
1D, 3456D,
|
||||
"Disk", new Date(10000000000L)};
|
||||
|
||||
String[] testCases = {
|
||||
|
@ -118,7 +118,7 @@ public class BigDecimalCompatibilityTest {
|
||||
bd = bd.divide(new BigDecimal(multiplier));
|
||||
}
|
||||
catch (ArithmeticException e) {
|
||||
bd = bd.divide(new BigDecimal(multiplier), BigDecimal.ROUND_HALF_EVEN);
|
||||
bd = bd.divide(new BigDecimal(multiplier), RoundingMode.HALF_EVEN);
|
||||
}
|
||||
check(num, bd, multiplier);
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
formatted.setLength(0);
|
||||
from = "123456789";
|
||||
to = sep_zero.substring(0, 399) + ",123,456,789";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(123456789L, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -810,7 +810,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
from = "123456789";
|
||||
to = "-" + nonsep_zero.substring(0, 300) + "123456789." +
|
||||
nonsep_zero.substring(0, 340);
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(123456789L, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -827,7 +827,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
from = Long.toString(Long.MAX_VALUE);
|
||||
to = sep_zero.substring(0, 373) +
|
||||
"19,807,040,619,342,712,359,383,728,129";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MAX_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -844,7 +844,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
from = Long.toString(Long.MAX_VALUE);
|
||||
to = "-1.9807040628566084396238503936" +
|
||||
nonsep_zero.substring(0, 312) + "E28";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MAX_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -862,7 +862,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
to = "-19807040619342712361531211776" +
|
||||
nonsep_zero.substring(0, 280) + "." +
|
||||
nonsep_zero.substring(0, 340) + "E-280";
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MIN_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -880,7 +880,7 @@ public class BigDecimalFormat extends IntlTest {
|
||||
to = sep_zero.substring(0, 373) +
|
||||
"19,807,040,628,566,084,398,385,987,584." +
|
||||
nonsep_zero.substring(0, 340);
|
||||
nf.format(new Long(from), formatted, new FieldPosition(0));
|
||||
nf.format(Long.MIN_VALUE, formatted, new FieldPosition(0));
|
||||
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
|
||||
}
|
||||
|
||||
|
@ -199,15 +199,15 @@ public class BigDecimalParse extends IntlTest {
|
||||
|
||||
// From: 1000.000
|
||||
// To: Double.POSITIVE_INFINITY
|
||||
check("1000.000", new Double(Double.POSITIVE_INFINITY));
|
||||
check("1000.000", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: -1000
|
||||
// To: Double.NEGATIVE_INFINITY
|
||||
check("-1000", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-1000", Double.NEGATIVE_INFINITY);
|
||||
|
||||
// From: -0.00
|
||||
// To: Double.NaN
|
||||
check("-0.00", new Double(Double.NaN));
|
||||
check("-0.00", Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,31 +220,31 @@ public class BigDecimalParse extends IntlTest {
|
||||
|
||||
// From: 1000.000
|
||||
// To: Double.POSITIVE_INFINITY
|
||||
check("1000.000", new Double(Double.POSITIVE_INFINITY));
|
||||
check("1000.000", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: -1000.000
|
||||
// To: Double.NEGATIVE_INFINITY
|
||||
check("-1000.000", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-1000.000", Double.NEGATIVE_INFINITY);
|
||||
|
||||
// From: 0.0
|
||||
// To: Double.NaN
|
||||
check("0.0", new Double(Double.NaN));
|
||||
check("0.0", Double.NaN);
|
||||
|
||||
// From: -0.0 (Double)
|
||||
// To: Double.NaN
|
||||
check("-0.0", new Double(Double.NaN));
|
||||
check("-0.0", Double.NaN);
|
||||
|
||||
// From: Double.NaN
|
||||
// To: Double.NaN
|
||||
check("\ufffd", new Double(Double.NaN));
|
||||
check("\ufffd", Double.NaN);
|
||||
|
||||
// From: Double.POSITIVE_INFINITY
|
||||
// To: Double.NaN
|
||||
check("\u221e", new Double(Double.POSITIVE_INFINITY));
|
||||
check("\u221e", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: Double.NEGATIVE_INFINITY
|
||||
// To: Double.NaN
|
||||
check("-\u221e", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-\u221e", Double.NEGATIVE_INFINITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,15 +257,15 @@ public class BigDecimalParse extends IntlTest {
|
||||
|
||||
// From: 1000
|
||||
// To: Double.POSITIVE_INFINITY
|
||||
check("1000", new Double(Double.POSITIVE_INFINITY));
|
||||
check("1000", Double.POSITIVE_INFINITY);
|
||||
|
||||
// From: -1000
|
||||
// To: Double.NEGATIVE_INFINITY
|
||||
check("-1000", new Double(Double.NEGATIVE_INFINITY));
|
||||
check("-1000", Double.NEGATIVE_INFINITY);
|
||||
|
||||
// From: -000 (Long)
|
||||
// To: Double.NaN
|
||||
check("-000", new Double(Double.NaN));
|
||||
check("-000", Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,20 +350,20 @@ public class BigDecimalParse extends IntlTest {
|
||||
{
|
||||
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"),
|
||||
new BigDecimal("5.0"), new BigDecimal("5.1"),
|
||||
new Double(Double.POSITIVE_INFINITY), new Double(Double.NaN),
|
||||
Double.POSITIVE_INFINITY, Double.NaN,
|
||||
new BigDecimal("0"), new BigDecimal("0.0"),
|
||||
new BigDecimal("-5"), new BigDecimal("-5.0"),
|
||||
new BigDecimal("-5.1"),
|
||||
new Double(Double.NEGATIVE_INFINITY), new Double(Double.NaN),
|
||||
Double.NEGATIVE_INFINITY, Double.NaN,
|
||||
},
|
||||
{
|
||||
new BigDecimal("0"), new BigDecimal("0.0"),
|
||||
new BigDecimal("-5"), new BigDecimal("-5.0"),
|
||||
new BigDecimal("-5.1"),
|
||||
new Double(Double.NEGATIVE_INFINITY), new Double(Double.NaN),
|
||||
Double.NEGATIVE_INFINITY, Double.NaN,
|
||||
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"),
|
||||
new BigDecimal("5.0"), new BigDecimal("5.1"),
|
||||
new Double(Double.POSITIVE_INFINITY),
|
||||
Double.POSITIVE_INFINITY,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -47,12 +47,12 @@ public class Bug4208135 {
|
||||
df.applyPattern("0.#E0");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
checkFormat(new Double(0.0), "0.E0");
|
||||
checkFormat(new Double(10.0), "1.E1");
|
||||
checkFormat(new Double(1000.0), "1.E3");
|
||||
checkFormat(new Long(0), "0.E0");
|
||||
checkFormat(new Long(10), "1.E1");
|
||||
checkFormat(new Long(1000), "1.E3");
|
||||
checkFormat(0.0, "0.E0");
|
||||
checkFormat(10.0, "1.E1");
|
||||
checkFormat(1000.0, "1.E3");
|
||||
checkFormat(0L, "0.E0");
|
||||
checkFormat(10L, "1.E1");
|
||||
checkFormat(1000L, "1.E3");
|
||||
checkFormat(new BigDecimal("0.0"), "0.E0");
|
||||
checkFormat(new BigDecimal("10.0"), "1.E1");
|
||||
checkFormat(new BigDecimal("1000.0"), "1.E3");
|
||||
@ -61,12 +61,12 @@ public class Bug4208135 {
|
||||
checkFormat(new BigInteger("1000"), "1.E3");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
checkFormat(new Double(0.0), "0E0");
|
||||
checkFormat(new Double(10.0), "1E1");
|
||||
checkFormat(new Double(1000.0), "1E3");
|
||||
checkFormat(new Long(0), "0E0");
|
||||
checkFormat(new Long(10), "1E1");
|
||||
checkFormat(new Long(1000), "1E3");
|
||||
checkFormat(0.0, "0E0");
|
||||
checkFormat(10.0, "1E1");
|
||||
checkFormat(1000.0, "1E3");
|
||||
checkFormat(0L, "0E0");
|
||||
checkFormat(10L, "1E1");
|
||||
checkFormat(1000L, "1E3");
|
||||
checkFormat(new BigDecimal("0.0"), "0E0");
|
||||
checkFormat(new BigDecimal("10.0"), "1E1");
|
||||
checkFormat(new BigDecimal("1000.0"), "1E3");
|
||||
@ -77,12 +77,12 @@ public class Bug4208135 {
|
||||
df.applyPattern("0.###");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
checkFormat(new Double(0.0), "0.");
|
||||
checkFormat(new Double(10.0), "10.");
|
||||
checkFormat(new Double(1000.0), "1000.");
|
||||
checkFormat(new Long(0), "0.");
|
||||
checkFormat(new Long(10), "10.");
|
||||
checkFormat(new Long(1000), "1000.");
|
||||
checkFormat(0.0, "0.");
|
||||
checkFormat(10.0, "10.");
|
||||
checkFormat(1000.0, "1000.");
|
||||
checkFormat(0L, "0.");
|
||||
checkFormat(10L, "10.");
|
||||
checkFormat(1000L, "1000.");
|
||||
checkFormat(new BigDecimal("0.0"), "0.");
|
||||
checkFormat(new BigDecimal("10.0"), "10.");
|
||||
checkFormat(new BigDecimal("1000.0"), "1000.");
|
||||
@ -91,12 +91,12 @@ public class Bug4208135 {
|
||||
checkFormat(new BigInteger("1000"), "1000.");
|
||||
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
checkFormat(new Double(0.0), "0");
|
||||
checkFormat(new Double(10.0), "10");
|
||||
checkFormat(new Double(1000.0), "1000");
|
||||
checkFormat(new Long(0), "0");
|
||||
checkFormat(new Long(10), "10");
|
||||
checkFormat(new Long(1000), "1000");
|
||||
checkFormat(0.0, "0");
|
||||
checkFormat(10.0, "10");
|
||||
checkFormat(1000.0, "1000");
|
||||
checkFormat(0L, "0");
|
||||
checkFormat(10L, "10");
|
||||
checkFormat(1000L, "1000");
|
||||
checkFormat(new BigDecimal("0.0"), "0");
|
||||
checkFormat(new BigDecimal("10.0"), "10");
|
||||
checkFormat(new BigDecimal("1000.0"), "1000");
|
||||
|
@ -51,20 +51,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", new Double(-252.5252525252525));
|
||||
checkFormat(252.5252525252525, "1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", -252.5252525252525);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "-8,888.8888");
|
||||
checkParse("8888.8888", new Double(2222.2222));
|
||||
checkFormat(-2222.2222, "-8,888.8888");
|
||||
checkParse("8888.8888", 2222.2222);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "4,000");
|
||||
checkParse("-4,000", new Long(-1000));
|
||||
checkFormat(1000L, "4,000");
|
||||
checkParse("-4,000", -1000L);
|
||||
|
||||
checkFormat(new Long(-250), "-1,000");
|
||||
checkParse("1000", new Long(250));
|
||||
checkFormat(-250L, "-1,000");
|
||||
checkParse("1000", 250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -104,20 +104,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "-1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", new Double(252.5252525252525));
|
||||
checkFormat(252.5252525252525, "-1,010.10101010101");
|
||||
checkParse("-1,010.10101010101", 252.5252525252525);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "8,888.8888");
|
||||
checkParse("8888.8888", new Double(-2222.2222));
|
||||
checkFormat(-2222.2222, "8,888.8888");
|
||||
checkParse("8888.8888", -2222.2222);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "-4,000");
|
||||
checkParse("-4,000", new Long(1000));
|
||||
checkFormat(1000L, "-4,000");
|
||||
checkParse("-4,000", 1000L);
|
||||
|
||||
checkFormat(new Long(-250), "1,000");
|
||||
checkParse("1000", new Long(-250));
|
||||
checkFormat(-250L, "1,000");
|
||||
checkParse("1000", -250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -157,30 +157,30 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(3333.3333333), "-9,999.9999999");
|
||||
checkParse("-10,000.00000000000", new Double(3333.3333333333335));// rounding error
|
||||
checkFormat(3333.3333333, "-9,999.9999999");
|
||||
checkParse("-10,000.00000000000", 3333.3333333333335);// rounding error
|
||||
|
||||
df.setParseIntegerOnly(true);
|
||||
checkFormat(new Double(-3333.3333333), "9,999.9999999");
|
||||
checkParse("10,000.00000000000", new Long(-3333));
|
||||
checkFormat(-3333.3333333, "9,999.9999999");
|
||||
checkParse("10,000.00000000000", -3333L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkFormat(new Double(-3333.3333333), "9,999.9999999");
|
||||
checkParse("10,000.00000000000", new Double(-3333.3333333333335));// rounding error
|
||||
checkFormat(-3333.3333333, "9,999.9999999");
|
||||
checkParse("10,000.00000000000", -3333.3333333333335);// rounding error
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(3333), "-9,999");
|
||||
checkFormat(3333L, "-9,999");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("-10,000", new Long(3333));
|
||||
checkParse("-10,000", 3333L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("-10000", new Double(3333.3333333333335));// rounding error
|
||||
checkParse("-10000", 3333.3333333333335);// rounding error
|
||||
|
||||
checkFormat(new Long(-3333), "9,999");
|
||||
checkFormat(-3333L, "9,999");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("10,000", new Long(-3333));
|
||||
checkParse("10,000", -3333L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("10000", new Double(-3333.3333333333335));// rounding error
|
||||
checkParse("10000", -3333.3333333333335);// rounding error
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -225,20 +225,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", new Double(-2.525252525252525E2));
|
||||
checkFormat(252.5252525252525, "1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", -2.525252525252525E2);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "-8.8888888E3");
|
||||
checkParse("8888.8888", new Double(2.2222222E3));
|
||||
checkFormat(-2222.2222, "-8.8888888E3");
|
||||
checkParse("8888.8888", 2.2222222E3);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "4E3");
|
||||
checkParse("-4E3", new Long(-1000));
|
||||
checkFormat(1000L, "4E3");
|
||||
checkParse("-4E3", -1000L);
|
||||
|
||||
checkFormat(new Long(-250), "-1E3");
|
||||
checkParse("1000", new Long(250));
|
||||
checkFormat(-250L, "-1E3");
|
||||
checkParse("1000", 250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -279,20 +279,20 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(252.5252525252525), "-1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", new Double(2.525252525252525E2));
|
||||
checkFormat(252.5252525252525, "-1.01010101010101E3");
|
||||
checkParse("-1.01010101010101E3", 2.525252525252525E2);
|
||||
|
||||
checkFormat(new Double(-2222.2222), "8.8888888E3");
|
||||
checkParse("8888.8888", new Double(-2.2222222E3));
|
||||
checkFormat(-2222.2222, "8.8888888E3");
|
||||
checkParse("8888.8888", -2.2222222E3);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(1000), "-4E3");
|
||||
checkParse("-4E3", new Long(1000));
|
||||
checkFormat(1000L, "-4E3");
|
||||
checkParse("-4E3", 1000L);
|
||||
|
||||
checkFormat(new Long(-250), "1E3");
|
||||
checkParse("1000", new Long(-250));
|
||||
checkFormat(-250L, "1E3");
|
||||
checkParse("1000", -250L);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
@ -333,30 +333,30 @@ public class Bug4833877 {
|
||||
/*
|
||||
* Test for double/Double
|
||||
*/
|
||||
checkFormat(new Double(3333.3333333), "-9.9999999999E3");
|
||||
checkParse("-1.00000000000000E3", new Double(3.33333333333333333E2));
|
||||
checkFormat(3333.3333333, "-9.9999999999E3");
|
||||
checkParse("-1.00000000000000E3", 3.33333333333333333E2);
|
||||
|
||||
df.setParseIntegerOnly(true);
|
||||
checkFormat(new Double(-3333.3333333), "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3", new Long(-3));
|
||||
checkFormat(-3333.3333333, "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3",-3L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkFormat(new Double(-3333.3333333), "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3", new Double(-3.33333333333333333E3));
|
||||
checkFormat(-3333.3333333, "9.9999999999E3");
|
||||
checkParse("10.00000000000000E3", -3.33333333333333333E3);
|
||||
|
||||
/*
|
||||
* Test for long/Long
|
||||
*/
|
||||
checkFormat(new Long(3333), "-9.999E3");
|
||||
checkFormat(3333L, "-9.999E3");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("-1.0E4", new Long(0));
|
||||
checkParse("-1.0E4", 0L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("-1.0E4", new Double(3333.3333333333335));
|
||||
checkParse("-1.0E4", 3333.3333333333335);
|
||||
|
||||
checkFormat(new Long(-3333), "9.999E3");
|
||||
checkFormat(-3333L, "9.999E3");
|
||||
df.setParseIntegerOnly(true);
|
||||
checkParse("10.0E4", new Long(-3));
|
||||
checkParse("10.0E4", -3L);
|
||||
df.setParseIntegerOnly(false);
|
||||
checkParse("10.0E4", new Double(-33333.3333333333336));
|
||||
checkParse("10.0E4", -33333.3333333333336);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
|
@ -71,47 +71,47 @@ public class Bug4838107 extends IntlTest {
|
||||
dfs = df.getDecimalFormatSymbols();
|
||||
|
||||
/* Test with default pattern */
|
||||
test(new Double(1234), "1,234");
|
||||
test(new Double(0.1234), "0.123"); // rounded
|
||||
test(new Double(-1234), "-1,234");
|
||||
test(new Double(-0.1234), "-0.123"); // rounded
|
||||
test(1234D, "1,234");
|
||||
test(0.1234, "0.123"); // rounded
|
||||
test(-1234D, "-1,234");
|
||||
test(-0.1234, "-0.123"); // rounded
|
||||
|
||||
test(new Double(Double.POSITIVE_INFINITY), "\u221e");
|
||||
test(new Double(Double.NEGATIVE_INFINITY), "-\u221e");
|
||||
test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix
|
||||
test(new Double(0.0), "0");
|
||||
test(new Double(-0.0), "-0"); // with the minus sign
|
||||
test(Double.POSITIVE_INFINITY, "\u221e");
|
||||
test(Double.NEGATIVE_INFINITY, "-\u221e");
|
||||
test(Double.NaN, "\ufffd"); // without prefix and suffix
|
||||
test(0.0, "0");
|
||||
test(-0.0, "-0"); // with the minus sign
|
||||
|
||||
/* Specify a pattern and the minus sign. */
|
||||
prepareFormatter("<P>#.###E00<S>", 'm');
|
||||
test(new Double(1234), "<P>1.234E03<S>");
|
||||
test(new Double(0.1234), "<P>1.234Em01<S>");
|
||||
test(new Double(-1234), "m<P>1.234E03<S>");
|
||||
test(new Double(-0.1234), "m<P>1.234Em01<S>");
|
||||
test(1234D, "<P>1.234E03<S>");
|
||||
test(0.1234, "<P>1.234Em01<S>");
|
||||
test(-1234D, "m<P>1.234E03<S>");
|
||||
test(-0.1234, "m<P>1.234Em01<S>");
|
||||
|
||||
prepareFormatter("<P>#.###E00<S>;#.###E00", 'm');
|
||||
test(new Double(1234), "<P>1.234E03<S>");
|
||||
test(new Double(0.1234), "<P>1.234Em01<S>");
|
||||
test(new Double(-1234), "1.234E03");
|
||||
test(new Double(-0.1234), "1.234Em01");
|
||||
test(1234D, "<P>1.234E03<S>");
|
||||
test(0.1234, "<P>1.234Em01<S>");
|
||||
test(-1234D, "1.234E03");
|
||||
test(-0.1234, "1.234Em01");
|
||||
|
||||
prepareFormatter("#.###E00;<P>#.###E00<S>", 'm');
|
||||
test(new Double(1234), "1.234E03");
|
||||
test(new Double(0.1234), "1.234Em01");
|
||||
test(new Double(-1234), "<P>1.234E03<S>");
|
||||
test(new Double(-0.1234), "<P>1.234Em01<S>");
|
||||
test(1234D, "1.234E03");
|
||||
test(0.1234, "1.234Em01");
|
||||
test(-1234D, "<P>1.234E03<S>");
|
||||
test(-0.1234, "<P>1.234Em01<S>");
|
||||
|
||||
prepareFormatter("<P>#.###E00<S>;<p>-#.###E00<s>", 'm');
|
||||
test(new Double(1234), "<P>1.234E03<S>");
|
||||
test(new Double(0.1234), "<P>1.234Em01<S>");
|
||||
test(new Double(-1234), "<p>m1.234E03<s>");
|
||||
test(new Double(-0.1234), "<p>m1.234Em01<s>");
|
||||
test(1234D, "<P>1.234E03<S>");
|
||||
test(0.1234, "<P>1.234Em01<S>");
|
||||
test(-1234D, "<p>m1.234E03<s>");
|
||||
test(-0.1234, "<p>m1.234Em01<s>");
|
||||
|
||||
test(new Double(Double.POSITIVE_INFINITY), "<P>\u221e<S>");
|
||||
test(new Double(Double.NEGATIVE_INFINITY), "<p>m\u221e<s>");
|
||||
test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix
|
||||
test(new Double(0.0), "<P>0E00<S>");
|
||||
test(new Double(-0.0), "<p>m0E00<s>"); // with the minus sign
|
||||
test(Double.POSITIVE_INFINITY, "<P>\u221e<S>");
|
||||
test(Double.NEGATIVE_INFINITY, "<p>m\u221e<s>");
|
||||
test(Double.NaN, "\ufffd"); // without prefix and suffix
|
||||
test(0.0, "<P>0E00<S>");
|
||||
test(-0.0, "<p>m0E00<s>"); // with the minus sign
|
||||
}
|
||||
|
||||
static void test_BigDecimal() {
|
||||
@ -151,19 +151,19 @@ public class Bug4838107 extends IntlTest {
|
||||
dfs = df.getDecimalFormatSymbols();
|
||||
|
||||
/* Test with default pattern */
|
||||
test(new Long(123456789), "123,456,789");
|
||||
test(new Long(-123456789), "-123,456,789");
|
||||
test(123456789L, "123,456,789");
|
||||
test(-123456789L, "-123,456,789");
|
||||
|
||||
test(new Long(0), "0");
|
||||
test(new Long(-0), "0");
|
||||
test(0L, "0");
|
||||
test(-0L, "0");
|
||||
|
||||
/* Specify a pattern and the minus sign. */
|
||||
prepareFormatter("<P>#,###<S>;<p>-#,###<s>", 'm');
|
||||
test(new Long(123456789), "<P>123,456,789<S>");
|
||||
test(new Long(-123456789), "<p>m123,456,789<s>");
|
||||
test(123456789L, "<P>123,456,789<S>");
|
||||
test(-123456789L, "<p>m123,456,789<s>");
|
||||
|
||||
test(new Long(0), "<P>0<S>");
|
||||
test(new Long(-0), "<P>0<S>");
|
||||
test(0L, "<P>0<S>");
|
||||
test(-0L, "<P>0<S>");
|
||||
}
|
||||
|
||||
static void test_BigInteger() {
|
||||
|
@ -84,7 +84,7 @@ public class Bug4944439 {
|
||||
}
|
||||
|
||||
int index = s.indexOf('.');
|
||||
Long l = new Long(s.substring(0, index));
|
||||
Long l = Long.valueOf(s.substring(0, index));
|
||||
if (!l.equals(number)) {
|
||||
err = true;
|
||||
System.err.println("Failed: DecimalFormat.parse(" + s +
|
||||
@ -101,7 +101,7 @@ public class Bug4944439 {
|
||||
number.getClass().getName());
|
||||
}
|
||||
|
||||
Double d = new Double(s);
|
||||
Double d = Double.valueOf(s);
|
||||
if (!d.equals(number)) {
|
||||
err = true;
|
||||
System.err.println("Failed: DecimalFormat.parse(" + s +
|
||||
|
@ -35,6 +35,7 @@ public class Bug4990596 {
|
||||
new DecimalFormat().format(new MutableInteger(0));
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class MutableInteger extends Number {
|
||||
public int value;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class Bug6278616 {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
|
||||
for (int j = 0; j < ints.length; j++) {
|
||||
String s_i = nf.format(new Integer(ints[j]));
|
||||
String s_i = nf.format(ints[j]);
|
||||
String s_ai = nf.format(new AtomicInteger(ints[j]));
|
||||
if (!s_i.equals(s_ai)) {
|
||||
throw new RuntimeException("format(AtomicInteger " + s_ai +
|
||||
@ -57,7 +57,7 @@ public class Bug6278616 {
|
||||
}
|
||||
|
||||
for (int j = 0; j < longs.length; j++) {
|
||||
String s_l = nf.format(new Long(longs[j]));
|
||||
String s_l = nf.format(longs[j]);
|
||||
String s_al = nf.format(new AtomicLong(longs[j]));
|
||||
if (!s_l.equals(s_al)) {
|
||||
throw new RuntimeException("format(AtomicLong " + s_al +
|
||||
|
@ -289,7 +289,7 @@ public class NumberRegression extends IntlTest {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0));
|
||||
if (!d.toString().equals("123.55456")) {
|
||||
errln("Result -> " + d.doubleValue());
|
||||
errln("Result -> " + d);
|
||||
}
|
||||
Locale.setDefault(savedLocale);
|
||||
}
|
||||
@ -395,11 +395,11 @@ public class NumberRegression extends IntlTest {
|
||||
Locale.setDefault(Locale.US);
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
String str = "0.1234";
|
||||
Double d1 = new Double(str);
|
||||
Double d1 = 0.1234;
|
||||
Double d2 = (Double) df.parse(str, new ParsePosition(0));
|
||||
logln(d1.toString());
|
||||
if (d2.doubleValue() != d1.doubleValue())
|
||||
errln("Bug 4095713 test failed, new double value : " + d2.doubleValue());
|
||||
errln("Bug 4095713 test failed, new double value : " + d2);
|
||||
Locale.setDefault(savedLocale);
|
||||
}
|
||||
|
||||
@ -870,7 +870,7 @@ public class NumberRegression extends IntlTest {
|
||||
DecimalFormat fmt = new DecimalFormat("#,##0.00");
|
||||
StringBuffer formatted = new StringBuffer();
|
||||
FieldPosition field = new FieldPosition(0);
|
||||
Double num = new Double(1234.5);
|
||||
Double num = 1234.5;
|
||||
fmt.format(num, formatted, field);
|
||||
if (field.getBeginIndex() != 0 && field.getEndIndex() != 5)
|
||||
errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex());
|
||||
@ -1416,7 +1416,7 @@ public class NumberRegression extends IntlTest {
|
||||
DecimalFormat fmt = new DecimalFormat("#",
|
||||
DecimalFormatSymbols.getInstance(Locale.US));
|
||||
for (int i=0; i<DATA.length; i+=3) {
|
||||
double in = Double.valueOf(DATA[i]).doubleValue();
|
||||
double in = Double.valueOf(DATA[i]);
|
||||
String pat = DATA[i+1];
|
||||
String exp = DATA[i+2];
|
||||
fmt.applyPattern(pat);
|
||||
@ -1622,7 +1622,7 @@ public class NumberRegression extends IntlTest {
|
||||
String str = Long.toString(DATA[i]);
|
||||
for (int m = 1; m <= 100; m++) {
|
||||
fmt.setMultiplier(m);
|
||||
long n = ((Number) fmt.parse(str)).longValue();
|
||||
long n = fmt.parse(str).longValue();
|
||||
if (n > 0 != DATA[i] > 0) {
|
||||
errln("\"" + str + "\" parse(x " + fmt.getMultiplier() +
|
||||
") => " + n);
|
||||
@ -1637,15 +1637,15 @@ public class NumberRegression extends IntlTest {
|
||||
*/
|
||||
public void Test4217661() {
|
||||
Object[] DATA = {
|
||||
new Double(0.001), "0",
|
||||
new Double(1.001), "1",
|
||||
new Double(0.006), "0.01",
|
||||
new Double(1.006), "1.01",
|
||||
0.001, "0",
|
||||
1.001, "1",
|
||||
0.006, "0.01",
|
||||
1.006, "1.01",
|
||||
};
|
||||
NumberFormat fmt = NumberFormat.getInstance(Locale.US);
|
||||
fmt.setMaximumFractionDigits(2);
|
||||
for (int i=0; i<DATA.length; i+=2) {
|
||||
String s = fmt.format(((Double) DATA[i]).doubleValue());
|
||||
String s = fmt.format((Double) DATA[i]);
|
||||
if (!s.equals(DATA[i+1])) {
|
||||
errln("FAIL: Got " + s + ", exp " + DATA[i+1]);
|
||||
}
|
||||
@ -1804,6 +1804,7 @@ public class NumberRegression extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class myformat implements Serializable
|
||||
{
|
||||
DateFormat _dateFormat = DateFormat.getDateInstance();
|
||||
@ -1817,6 +1818,7 @@ class myformat implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class MyNumberFormatTest extends NumberFormat {
|
||||
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
|
||||
return new StringBuffer("");
|
||||
@ -1825,6 +1827,6 @@ class MyNumberFormatTest extends NumberFormat {
|
||||
return new StringBuffer("");
|
||||
}
|
||||
public Number parse(String text, ParsePosition parsePosition) {
|
||||
return new Integer(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -130,11 +130,11 @@ public class NumberRoundTrip extends IntlTest {
|
||||
}
|
||||
|
||||
public void doTest(NumberFormat fmt, double value) {
|
||||
doTest(fmt, new Double(value));
|
||||
doTest(fmt, Double.valueOf(value));
|
||||
}
|
||||
|
||||
public void doTest(NumberFormat fmt, long value) {
|
||||
doTest(fmt, new Long(value));
|
||||
doTest(fmt, Long.valueOf(value));
|
||||
}
|
||||
|
||||
static double proportionalError(Number a, Number b) {
|
||||
|
@ -403,7 +403,7 @@ public class NumberTest extends IntlTest
|
||||
float[] parseExpected = { 0, 0, 12345, -12345 };
|
||||
|
||||
for (int i = 0; i < parseInput.length; i++) {
|
||||
float result = ((Number) format.parse(parseInput[i])).floatValue();
|
||||
float result = format.parse(parseInput[i]).floatValue();
|
||||
if (result != parseExpected[i]) {
|
||||
errln("FAIL: Expected " + parseExpected[i] + ", got " + result);
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public class SerializationLoadTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormat implements Serializable
|
||||
{
|
||||
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
|
||||
@ -73,6 +74,7 @@ class CheckDecimalFormat implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormatSymbols implements Serializable
|
||||
{
|
||||
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();
|
||||
|
@ -57,6 +57,7 @@ public class SerializationSaveTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormat implements Serializable
|
||||
{
|
||||
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
|
||||
@ -68,6 +69,7 @@ class CheckDecimalFormat implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CheckDecimalFormatSymbols implements Serializable
|
||||
{
|
||||
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();
|
||||
|
@ -37,6 +37,7 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.text.AttributedCharacterIterator.Attribute;
|
||||
|
||||
/**
|
||||
* FormatTester creates Formats, and tests the resulting FieldPositions
|
||||
@ -94,7 +95,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* Any lines starting with {@code '#'} are comment lines and ignored.
|
||||
*/
|
||||
public class FormatIteratorTest extends IntlTest {
|
||||
private static HashMap attrs;
|
||||
private Format format;
|
||||
private Object value;
|
||||
private String text;
|
||||
@ -143,30 +143,31 @@ public class FormatIteratorTest extends IntlTest {
|
||||
"dateFormat.props"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void _test(File file) {
|
||||
try {
|
||||
attrs = new HashMap();
|
||||
logln("testing: " + file);
|
||||
PParser parser = new PParser();
|
||||
Hashtable contents = parser.parse(new BufferedReader(
|
||||
Map<String,Object> contents = parser.parse(new BufferedReader(
|
||||
new FileReader(file)));
|
||||
Vector test = (Vector)contents.get("tests");
|
||||
List<Object> test = (List)contents.get("tests");
|
||||
|
||||
for (int counter = 0; counter < test.size(); counter++) {
|
||||
logln("creating: " + (counter / 2));
|
||||
|
||||
AttributedCharacterIterator iterator =
|
||||
create((Hashtable)test.get(counter));
|
||||
create((Map)test.get(counter));
|
||||
|
||||
logln("verifying: " + (counter / 2));
|
||||
verify(iterator, (Hashtable)test.get(++counter));
|
||||
verify(iterator, (Map)test.get(++counter));
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
errln("Error reading: " + ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public void verify(AttributedCharacterIterator iterator,Hashtable table) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void verify(AttributedCharacterIterator iterator,Map<String,Object> table) {
|
||||
int length = Integer.parseInt((String)table.get("length"));
|
||||
|
||||
// Verify the text
|
||||
@ -185,10 +186,10 @@ public class FormatIteratorTest extends IntlTest {
|
||||
for (int counter = 0; counter < length; counter++) {
|
||||
iterator.setIndex(counter);
|
||||
if (!verifyAttributes(iterator.getAttributes().keySet(),
|
||||
makeAttributes((Vector)table.get(Integer.
|
||||
makeAttributes((List)table.get(Integer.
|
||||
toString(counter))))) {
|
||||
errln("Attributes don't match at " + counter + " expecting " +
|
||||
makeAttributes((Vector)table.get(Integer.toString
|
||||
makeAttributes((List)table.get(Integer.toString
|
||||
(counter))) + " got " +
|
||||
iterator.getAttributes().keySet());
|
||||
}
|
||||
@ -196,10 +197,10 @@ public class FormatIteratorTest extends IntlTest {
|
||||
for (int counter = length - 1; counter >= 0; counter--) {
|
||||
iterator.setIndex(counter);
|
||||
if (!verifyAttributes(iterator.getAttributes().keySet(),
|
||||
makeAttributes((Vector)table.get(Integer.
|
||||
makeAttributes((List)table.get(Integer.
|
||||
toString(counter))))) {
|
||||
errln("Attributes don't match at " + counter + " expecting " +
|
||||
makeAttributes((Vector)table.get(Integer.toString
|
||||
makeAttributes((List)table.get(Integer.toString
|
||||
(counter))) + " got " +
|
||||
iterator.getAttributes().keySet());
|
||||
}
|
||||
@ -207,31 +208,33 @@ public class FormatIteratorTest extends IntlTest {
|
||||
verifyLimits(iterator, table);
|
||||
|
||||
text = escapeIfNecessary((String)table.get("text"));
|
||||
Vector fps = (Vector)table.get("fieldPositions");
|
||||
List<Object> fps = (List)table.get("fieldPositions");
|
||||
|
||||
if (fps != null) {
|
||||
for (int counter = 0; counter < fps.size(); counter++) {
|
||||
verifyFieldPosition(counter, (Hashtable)fps.get(counter));
|
||||
verifyFieldPosition(counter,(Map)fps.get(counter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void verifyLimits(AttributedCharacterIterator iterator,
|
||||
Hashtable table) {
|
||||
Vector limits = (Vector)table.get("limits");
|
||||
Map<String,Object> table) {
|
||||
List<Object> limits = (List)table.get("limits");
|
||||
|
||||
if (limits != null) {
|
||||
for (int counter = 0; counter < limits.size(); counter++) {
|
||||
verifyLimit(iterator, (Hashtable)limits.get(counter));
|
||||
verifyLimit(iterator, (Map)limits.get(counter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyLimit(AttributedCharacterIterator iterator,
|
||||
Hashtable table) {
|
||||
Map<String,Object> table) {
|
||||
int begin = Integer.parseInt((String)table.get("begin"));
|
||||
int end = Integer.parseInt((String)table.get("end"));
|
||||
Set attrs = makeAttributes((Vector)table.get("attributes"));
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Attribute> attrs = makeAttributes((List)table.get("attributes"));
|
||||
String begin2S = (String)table.get("begin2");
|
||||
int begin2 = (begin2S != null) ? Integer.parseInt(begin2S) : begin;
|
||||
String end2S = (String)table.get("end2");
|
||||
@ -262,9 +265,9 @@ public class FormatIteratorTest extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean verifyAttributes(Set a, Set b) {
|
||||
boolean aEmpty = (a.size() == 0);
|
||||
boolean bEmpty = (b.size() == 0);
|
||||
private boolean verifyAttributes(Set<Attribute> a, Set<Attribute> b) {
|
||||
boolean aEmpty = a.isEmpty();
|
||||
boolean bEmpty = b.isEmpty();
|
||||
|
||||
if (aEmpty && bEmpty) {
|
||||
return true;
|
||||
@ -284,14 +287,14 @@ public class FormatIteratorTest extends IntlTest {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private void verifyFieldPosition(int index, Hashtable table) {
|
||||
private void verifyFieldPosition(int index, Map<String,Object> table) {
|
||||
Object o = table.get("field");
|
||||
int begin = Integer.parseInt((String)table.get("begin"));
|
||||
int end = Integer.parseInt((String)table.get("end"));
|
||||
|
||||
if (o != null) {
|
||||
FieldPosition fp = new FieldPosition(((Integer)
|
||||
lookupField((String)o)).intValue());
|
||||
lookupField((String)o)));
|
||||
|
||||
verifyFieldPosition(fp, begin, end, index);
|
||||
}
|
||||
@ -322,11 +325,11 @@ public class FormatIteratorTest extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
public AttributedCharacterIterator create(Hashtable table) {
|
||||
public AttributedCharacterIterator create(Map<String,Object> table) {
|
||||
format = (Format)createInstance((String)table.get("class"),
|
||||
((Vector)table.get("args")).toArray());
|
||||
((List)table.get("args")).toArray());
|
||||
value = createInstance((String)table.get("valueClass"),
|
||||
((Vector)table.get("valueArgs")).toArray());
|
||||
((List)table.get("valueArgs")).toArray());
|
||||
|
||||
logln("Created format: " + format + " value " + value);
|
||||
AttributedCharacterIterator aci = format.
|
||||
@ -343,11 +346,12 @@ public class FormatIteratorTest extends IntlTest {
|
||||
private Object createInstance(String className, Object[] args) {
|
||||
if (className.equals("java.lang.reflect.Array")) {
|
||||
for (int counter = 0; counter < args.length; counter++) {
|
||||
if (args[counter] instanceof Vector) {
|
||||
Vector v = (Vector)args[counter];
|
||||
if (args[counter] instanceof List) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> v = (List<Object>)args[counter];
|
||||
|
||||
args[counter] = createInstance((String)v.get(0),
|
||||
((Vector)v.get(1)).toArray());
|
||||
((List)v.get(1)).toArray());
|
||||
}
|
||||
}
|
||||
return args;
|
||||
@ -361,9 +365,9 @@ public class FormatIteratorTest extends IntlTest {
|
||||
} else if (className.equals("java.util.concurrent.atomic.AtomicLong")) {
|
||||
return new AtomicLong(Long.valueOf((String)args[0]));
|
||||
} else {
|
||||
Class klass = lookupClass(className);
|
||||
Constructor cons = klass.getConstructor(
|
||||
new Class[] { String.class });
|
||||
Class<?> klass = lookupClass(className);
|
||||
Constructor<?> cons = klass.getConstructor(
|
||||
new Class<?>[] { String.class });
|
||||
Object value = cons.newInstance(args);
|
||||
|
||||
return value;
|
||||
@ -374,20 +378,20 @@ public class FormatIteratorTest extends IntlTest {
|
||||
}
|
||||
}
|
||||
|
||||
private Class lookupClass(String name) throws ClassNotFoundException {
|
||||
private Class<?> lookupClass(String name) throws ClassNotFoundException {
|
||||
try {
|
||||
Class klass = Class.forName(name);
|
||||
Class<?> klass = Class.forName(name);
|
||||
|
||||
return klass;
|
||||
} catch (ClassNotFoundException e1) {}
|
||||
|
||||
try {
|
||||
Class klass = Class.forName("java.lang." + name);
|
||||
Class<?> klass = Class.forName("java.lang." + name);
|
||||
|
||||
return klass;
|
||||
} catch (ClassNotFoundException e1) {}
|
||||
|
||||
Class klass = Class.forName("java.text." + name);
|
||||
Class<?> klass = Class.forName("java.text." + name);
|
||||
|
||||
return klass;
|
||||
}
|
||||
@ -397,7 +401,7 @@ public class FormatIteratorTest extends IntlTest {
|
||||
|
||||
try {
|
||||
int dotIndex = name.indexOf('.');
|
||||
Class klass = lookupClass(name.substring(0, dotIndex));
|
||||
Class<?> klass = lookupClass(name.substring(0, dotIndex));
|
||||
String fieldName = name.substring(dotIndex + 1);
|
||||
Field[] fields = klass.getFields();
|
||||
|
||||
@ -429,8 +433,8 @@ public class FormatIteratorTest extends IntlTest {
|
||||
return string;
|
||||
}
|
||||
|
||||
public Set makeAttributes(Vector names) {
|
||||
HashSet set = new HashSet(Math.max(1, names.size()));
|
||||
public Set<Attribute> makeAttributes(List<Object> names) {
|
||||
Set<Attribute> set = new HashSet<>(Math.max(1, names.size()));
|
||||
|
||||
for (int counter = 0; counter < names.size(); counter++) {
|
||||
set.add(makeAttribute((String)names.get(counter)));
|
||||
|
@ -58,7 +58,7 @@ public class PParser {
|
||||
public PParser() {
|
||||
}
|
||||
|
||||
public Hashtable parse(Reader r) throws IOException {
|
||||
public Map<String,Object> parse(Reader r) throws IOException {
|
||||
this.reader = r;
|
||||
bufferedToken = false;
|
||||
lineNumber = 0;
|
||||
@ -91,23 +91,23 @@ public class PParser {
|
||||
}
|
||||
|
||||
protected Object parseArray() throws IOException {
|
||||
Vector array = new Vector();
|
||||
int token;
|
||||
List<Object> array = new ArrayList<>();
|
||||
int token;
|
||||
|
||||
while ((token = getToken()) != CLOSE_ARRAY) {
|
||||
if (token == MORE) {
|
||||
token = getToken();
|
||||
}
|
||||
if (token != CLOSE_ARRAY) {
|
||||
array.addElement(parseValue(token));
|
||||
array.add(parseValue(token));
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
protected Hashtable parsePair() throws IOException {
|
||||
Hashtable ht = new Hashtable(11);
|
||||
int token;
|
||||
protected Map<String,Object> parsePair() throws IOException {
|
||||
Map<String,Object> ht = new HashMap<>(11);
|
||||
int token;
|
||||
|
||||
while ((token = getToken()) != CLOSE_PAIR) {
|
||||
if (token != STRING) {
|
||||
@ -133,11 +133,12 @@ public class PParser {
|
||||
}
|
||||
|
||||
protected int getToken() throws IOException {
|
||||
int token = getToken(false, false);
|
||||
int token = getToken(false, false);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
protected int getToken(boolean wantsWS, boolean inString)
|
||||
throws IOException {
|
||||
if (bufferedToken) {
|
||||
@ -225,31 +226,26 @@ public class PParser {
|
||||
throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void dump(Object o) {
|
||||
if (o instanceof String) {
|
||||
System.out.print(o);
|
||||
} else if(o instanceof Vector) {
|
||||
Enumeration e = ((Vector)o).elements();
|
||||
|
||||
} else if(o instanceof List) {
|
||||
dump(" (");
|
||||
while (e.hasMoreElements()) {
|
||||
dump(e.nextElement());
|
||||
((List)o).forEach((l) -> {
|
||||
dump(l);
|
||||
dump(" -- ");
|
||||
}
|
||||
});
|
||||
dump(" )");
|
||||
} else {
|
||||
Hashtable ht = (Hashtable)o;
|
||||
Enumeration e = ht.keys();
|
||||
|
||||
Map<String,Object> ht = (Map<String,Object>)o;
|
||||
dump(" {");
|
||||
while (e.hasMoreElements()) {
|
||||
Object key = e.nextElement();
|
||||
|
||||
dump(key);
|
||||
ht.keySet().forEach(l -> {
|
||||
dump(l);
|
||||
dump(" = ");
|
||||
dump(ht.get(key));
|
||||
dump(ht.get(l));
|
||||
dump(";");
|
||||
}
|
||||
});
|
||||
dump(" }");
|
||||
}
|
||||
}
|
||||
@ -259,9 +255,9 @@ public class PParser {
|
||||
System.out.println("need filename");
|
||||
} else {
|
||||
try {
|
||||
FileReader fr = new FileReader(args[0]);
|
||||
PParser parser = new PParser();
|
||||
Hashtable ht = parser.parse(fr);
|
||||
FileReader fr = new FileReader(args[0]);
|
||||
PParser parser = new PParser();
|
||||
Map<String,Object> ht = parser.parse(fr);
|
||||
|
||||
dump(ht);
|
||||
System.out.println();
|
||||
|
Loading…
Reference in New Issue
Block a user