2362N/A * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A/* Type-specific source code for unit test 0N/A * Regenerate the BasicX classes via genBasic.sh whenever this file changes. 0N/A * We check in the generated source files so that the test tree can be used 0N/A * independently of the rest of the source tree. 0N/A //--------------------------------------------------------------------- 0N/A // Date/Time conversions applicable to Calendar, Date, and long. 0N/A //--------------------------------------------------------------------- 0N/A // Date/long do not have timezone information so they will always use 0N/A // the default timezone. 0N/A // Date (implemented via conversion to Calendar) 0N/A // long (implemented via conversion to Calendar) 0N/A // repeat all tests for upper case variant (%T) 0N/A for (
int i =
0; i <
24; i++) {
0N/A // GregorianCalendar(int year, int month, int dayOfMonth, 0N/A // int hourOfDay, int minute, int second); 0N/A //----------------------------------------------------------------- 0N/A // DateTime.HOUR_OF_DAY - 'k' (0 - 23) -- like H 0N/A //----------------------------------------------------------------- 0N/A //----------------------------------------------------------------- 0N/A // DateTime.HOUR - 'l' (1 - 12) -- like I 0N/A //----------------------------------------------------------------- 0N/A v = (v ==
0 ?
12 : v);
0N/A //----------------------------------------------------------------- 0N/A // DateTime.HOUR_OF_DAY_0 - 'H' (00 - 23) [zero padded] 0N/A //----------------------------------------------------------------- 0N/A //----------------------------------------------------------------- 0N/A // DateTime.HOUR_0 - 'I' (01 - 12) 0N/A //----------------------------------------------------------------- 0N/A //----------------------------------------------------------------- 0N/A // DateTime.AM_PM - (am or pm) 0N/A //----------------------------------------------------------------- 0N/A // Any characters not explicitly defined as conversions, date/time 0N/A // conversion suffixes, or flags are illegal and are reserved for 0N/A // future extensions. Use of such a character in a format string will 0N/A // cause an UnknownFormatConversionException or 0N/A // UnknownFormatFlagsException to be thrown. 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A test(
"%4$2s %3$2s %2$2s %1$2s",
" d c b a",
"a",
"b",
"c",
"d");
0N/A test(
"Amount gained or lost since last statement: $ %,(.2f",
0N/A "Amount gained or lost since last statement: $ (6,217.58)",
0N/A test(
"Unable to open file '%1$s': %2$s",
0N/A "Unable to open file 'food': No such file or directory",
0N/A "food",
"No such file or directory");
0N/A test(
"Duke's Birthday: %1$tB %1$te, %1$tY",
0N/A "Duke's Birthday: May 23, 1995",
0N/A test(
"Duke's Birthday: %1$tB %1$te, %1$tY",
0N/A "Duke's Birthday: May 23, 1995",
0N/A test(
"Duke's Birthday: %1$tB %1$te, %1$tY",
0N/A "Duke's Birthday: May 23, 1995",
0N/A test(
"%4$s %3$s %2$s %1$s %4$s %3$s %2$s %1$s",
0N/A "d c b a d c b a",
"a",
"b",
"c",
"d");
0N/A test(
"%s %s %<s %<s",
"a b b b",
"a",
"b",
"c",
"d");
0N/A test(
"%s %s %s %s",
"a b c d",
"a",
"b",
"c",
"d");
0N/A test(
"%2$s %s %<s %s",
"b a a b",
"a",
"b",
"c",
"d");
0N/A //--------------------------------------------------------------------- 0N/A // General conversion applicable to any argument. 0N/A //--------------------------------------------------------------------- 0N/A // localization is possible. 0N/A // If you pass in a single array to a varargs method, the compiler 0N/A // uses it as the array of arguments rather than treating it as a 0N/A // single array-type argument. 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // correct or side-effect of implementation? 0N/A //--------------------------------------------------------------------- 0N/A // General conversion applicable to any argument. 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // General conversion applicable to any argument. 0N/A //--------------------------------------------------------------------- 0N/A test(
"%s",
"Hello, Duke",
"Hello, Duke");
0N/A test(
"%S",
"HELLO, DUKE",
"Hello, Duke");
0N/A test(
"%20S",
" HELLO, DUKE",
"Hello, Duke");
0N/A test(
"%20s",
" Hello, Duke",
"Hello, Duke");
0N/A test(
"%-20s",
"Hello, Duke ",
"Hello, Duke");
0N/A test(
"%-20.5s",
"Hello ",
"Hello, Duke");
0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // General conversion applicable to any argument. 0N/A //--------------------------------------------------------------------- 0N/A test(
"%10h",
" ddf63471",
"Hello, Duke");
0N/A test(
"%-10h",
"ddf63471 ",
"Hello, Duke");
0N/A test(
"%-10H",
"DDF63471 ",
"Hello, Duke");
0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // Numeric conversion applicable to byte, short, int, long, and 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %d - int and long 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // Numeric conversion applicable to byte, short, int, long, and 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // Numeric conversion applicable to byte, short, int, long, and 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // BigInteger - errors 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A test(
"%s",
"3.141592653589793115997963468544185161590576171875",
pi);
0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // Floating-point conversions applicable to float, double, and 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %e - float and double 0N/A //--------------------------------------------------------------------- 0N/A // double PI = 3.141 592 653 589 793 238 46; 0N/A // = 13962455701329742638131355433930076081862072808 ... e+149 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %e - boundary problems 0N/A //--------------------------------------------------------------------- 0N/A test(
"%3.0e",
"1e+06",
1000000.00);
0N/A test(
"%3.0e",
"1e+07",
10000000.00);
0N/A test(
"%3.0e",
"1e+08",
100000000.00);
0N/A //--------------------------------------------------------------------- 0N/A // Floating-point conversions applicable to float, double, and 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %f - boundary problems 0N/A //--------------------------------------------------------------------- 0N/A test(
"%3.0f",
"100000",
100000.00);
0N/A test(
"%3.0f",
"1000000",
1000000.00);
0N/A test(
"%3.0f",
"10000000",
10000000.00);
0N/A test(
"%3.0f",
"100000000",
100000000.00);
0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // Float can not accurately store 1e6 * PI. 0N/A //--------------------------------------------------------------------- 0N/A // %f - float, double, Double, BigDecimal 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // Floating-point conversions applicable to float, double, and 0N/A //--------------------------------------------------------------------- 0N/A test(
"%3.2g",
"9.9e-06",
0.0000099);
0N/A test(
"%3.2g",
"9.9e-05",
0.000099);
0N/A test(
"%3.0g",
"1e+06",
1000000.00);
0N/A test(
"%3.0g",
"1e+07",
10000000.00);
0N/A test(
"%3.9g",
"100000000",
100000000.00);
0N/A test(
"%3.10g",
"100000000.0",
100000000.00);
0N/A // = 13962455701329742638131355433930076081862072808 ... e+149 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // Float can not accurately store 1e6 * PI. 0N/A //--------------------------------------------------------------------- 0N/A // Floating-point conversions applicable to float, double, and 0N/A //--------------------------------------------------------------------- 0N/A test(
"%.11a",
"0x0.00000000000p0",
0.0);
0N/A test(
"%.11a",
"-0x0.00000000000p0", -
0.0);
0N/A test(
"%.11a",
"0x1.00000000000p0",
1.0);
0N/A test(
"%.11a",
"-0x1.00000000000p0", -
1.0);
0N/A test(
"%.11a",
"0x1.80000000000p1",
3.0);
0N/A test(
"%.11a",
"0x1.00000000000p-1022",
0N/A test(
"%.11a",
"0x1.ffffffffffep-1023",
0N/A test(
"%.11a",
"0x1.08000000000p-1069",
0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - Boundaries 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - NaN 0N/A //--------------------------------------------------------------------- 0N/A// test("%F", "NAN", Float.NaN); 0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - +0.0 0N/A //--------------------------------------------------------------------- 0N/A// test("%F", "0.000000", +0.0); 0N/A test(
"%+e",
"+0.000000e+00", +
0.0);
0N/A test(
"% e",
" 0.000000e+00", +
0.0);
0N/A test(
"%+E",
"+0.000000E+00", +
0.0);
0N/A test(
"% E",
" 0.000000E+00", +
0.0);
0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - -0.0 0N/A //--------------------------------------------------------------------- 0N/A// test("%F", "-0.000000", -0.0); 0N/A test(
"%+e",
"-0.000000e+00", -
0.0);
0N/A test(
"%+E",
"-0.000000E+00", -
0.0);
0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - +Infinity 0N/A //--------------------------------------------------------------------- 0N/A// test("%F", "INFINITY", Float.POSITIVE_INFINITY); 0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - -Infinity 0N/A //--------------------------------------------------------------------- 0N/A// test("%F", "-INFINITY", Float.NEGATIVE_INFINITY); 0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - Float.MIN_VALUE 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - Float.MAX_VALUE 0N/A //--------------------------------------------------------------------- 0N/A test(
"%,f",
"340,282,346,638,528,860,000,000,000,000,000,000,000.000000",
0N/A test(
"%60.5f",
" 340282346638528860000000000000000000000.00000",
0N/A test(
"%60.13f",
" 340282346638528860000000000000000000000.0000000000000",
0N/A test(
"%61.20f",
" 340282346638528860000000000000000000000.00000000000000000000",
0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - Double.MIN_VALUE 0N/A //--------------------------------------------------------------------- 0N/A test(
"%30.350f",
"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000490000000000000000000000000",
0N/A //--------------------------------------------------------------------- 0N/A // %f, %e, %g, %a - Double.MAX_VALUE 0N/A //--------------------------------------------------------------------- 0N/A test(
"%f",
"179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000",
0N/A test(
"%,f",
"179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000000",
0N/A test(
"%,(f",
"(179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000000)",
0N/A test(
"%,30.5f",
"179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.00000",
0N/A test(
"%30.13f",
"179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000000000000",
0N/A test(
"%30.20f",
"179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00000000000000000000",
0N/A //--------------------------------------------------------------------- 0N/A // Date/Time conversions applicable to Calendar, Date, and long. 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %t - create test Calendar 0N/A //--------------------------------------------------------------------- 0N/A // Get the supported ids for GMT-08:00 (Pacific Standard Time) 0N/A // Create a Pacific Standard Time time zone 0N/A // public GregorianCalendar(TimeZone zone, Locale aLocale); 0N/A // public final void set(int year, int month, int date, 0N/A // int hourOfDay, int minute, int second); 0N/A //--------------------------------------------------------------------- 0N/A // %t - Minutes, {nano,milli}*seconds 0N/A // testDateTime() verifies the expected output for all applicable types 0N/A // (Calendar, Date, and long). It also verifies output for "%t" and 0N/A // "%T". Thus it is sufficient to invoke that method once per 0N/A //--------------------------------------------------------------------- 0N/A// testDateTime("%tQ", "801283714584", c0); 0N/A //--------------------------------------------------------------------- 0N/A // testHours() iterates through all twenty-four hours to verify 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %t - Portions of date [ day, month, dates, weeks ] 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // %tz should always adjust for DST 0N/A //--------------------------------------------------------------------- 0N/A // Artificial TimeZone based on PST with 3:15 DST always in effect 0N/A // 24hrs - 1m = 60 * 60 * 1000 * 24 - 1 0N/A (
int)(
60 *
60 *
1000 *
3.25));
0N/A // Restore the TimeZone and verify 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A // perhaps an IllegalFormatArgumentIndexException should be defined?