BasicDouble.java revision 2362
2085N/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. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1472N/A * or visit www.oracle.com if you need additional information or have any 0N/A/* Type-specific source code for unit test 1879N/A * Regenerate the BasicX classes via genBasic.sh whenever this file changes. 1879N/A * We check in the generated source files so that the test tree can be used 1879N/A * independently of the rest of the source tree. 1879N/A// -- This file was mechanically generated: Do not edit! -- // 0N/A private static double mult(
double v,
double mul) {
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 //--------------------------------------------------------------------- 1601N/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? 1887N/A //--------------------------------------------------------------------- 1887N/A // General conversion applicable to any argument. 1887N/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. 1827N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- 0N/A //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- test(
"%s",
"3.141592653589793",
pi);
//--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Floating-point conversions applicable to float, double, and //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- // double PI = 3.141 592 653 589 793 238 46; test(
"%e",
"3.141593e+00",
pi);
test(
"%E",
"3.141593E+00",
pi);
test(
"%10.3e",
" 3.142e+00",
pi);
test(
"%010.3e",
"03.142e+00",
pi);
test(
"%-12.3e",
"3.142e+00 ",
pi);
test(
"%.3e",
"3.142e+00",
pi);
// = 13962455701329742638131355433930076081862072808 ... e+149 test(
"%+.3e",
"+3.142e+00",
pi);
test(
"% .3e",
" 3.142e+00",
pi);
test(
"%(.4e",
"(3.1416e+06)",
mult(
pi, -
1000000.0));
//--------------------------------------------------------------------- // %e - boundary problems //--------------------------------------------------------------------- test(
"%3.0e",
"1e-06",
0.000001);
test(
"%3.0e",
"1e-05",
0.00001);
test(
"%3.0e",
"1e-04",
0.0001);
test(
"%3.0e",
"1e-03",
0.001);
test(
"%3.0e",
"1e-02",
0.01);
test(
"%3.0e",
"1e-01",
0.1);
test(
"%3.0e",
"9e-01",
0.9);
test(
"%3.1e",
"9.0e-01",
0.9);
test(
"%3.0e",
"1e+00",
1.00);
test(
"%3.0e",
"1e+01",
10.00);
test(
"%3.0e",
"1e+02",
99.19);
test(
"%3.1e",
"9.9e+01",
99.19);
test(
"%3.0e",
"1e+02",
99.99);
test(
"%3.0e",
"1e+02",
100.00);
test(
"%#3.0e",
"1.e+03",
1000.00);
test(
"%3.0e",
"1e+04",
10000.00);
test(
"%3.0e",
"1e+05",
100000.00);
test(
"%3.0e",
"1e+06",
1000000.00);
test(
"%3.0e",
"1e+07",
10000000.00);
test(
"%3.0e",
"1e+08",
100000000.00);
//--------------------------------------------------------------------- // Floating-point conversions applicable to float, double, and //--------------------------------------------------------------------- test(
"%010.3f",
"000003.142",
pi);
test(
"%-10.3f",
"3.142 ",
pi);
//--------------------------------------------------------------------- // %f - boundary problems //--------------------------------------------------------------------- test(
"%3.0f",
" 0",
0.000001);
test(
"%3.0f",
" 0",
0.00001);
test(
"%3.0f",
" 0",
0.0001);
test(
"%3.0f",
" 0",
0.001);
test(
"%3.0f",
" 0",
0.01);
test(
"%3.0f",
" 0",
0.1);
test(
"%3.0f",
" 1",
0.9);
test(
"%3.1f",
"0.9",
0.9);
test(
"%3.0f",
" 1",
1.00);
test(
"%3.0f",
" 10",
10.00);
test(
"%3.0f",
" 99",
99.19);
test(
"%3.1f",
"99.2",
99.19);
test(
"%3.0f",
"100",
99.99);
test(
"%3.0f",
"100",
100.00);
test(
"%#3.0f",
"1000.",
1000.00);
test(
"%3.0f",
"10000",
10000.00);
test(
"%3.0f",
"100000",
100000.00);
test(
"%3.0f",
"1000000",
1000000.00);
test(
"%3.0f",
"10000000",
10000000.00);
test(
"%3.0f",
"100000000",
100000000.00);
//--------------------------------------------------------------------- // %f - float, double, Double, BigDecimal //--------------------------------------------------------------------- test(
"%.3f",
"-3141592.654",
mult(
pi, -
1000000.0));
test(
"%,.4f",
"3,141,592.6536",
mult(
pi,
1000000.0));
test(
"%,.4f",
"-3,141,592.6536",
mult(
pi, -
1000000.0));
test(
"%(.4f",
"3141592.6536",
mult(
pi,
1000000.0));
test(
"%(.4f",
"(3141592.6536)",
mult(
pi, -
1000000.0));
test(
"%(,.4f",
"3,141,592.6536",
mult(
pi,
1000000.0));
test(
"%(,.4f",
"(3,141,592.6536)",
mult(
pi, -
1000000.0));
//--------------------------------------------------------------------- // Floating-point conversions applicable to float, double, and //--------------------------------------------------------------------- test(
"%010.3g",
"0000003.14",
pi);
test(
"%.3g",
"-3.14e+08",
mult(
pi, -
100000000.0));
test(
"%3.0g",
"1e-06",
0.000001);
test(
"%3.0g",
"1e-05",
0.00001);
test(
"%3.0g",
"1e-05",
0.0000099);
test(
"%3.1g",
"1e-05",
0.0000099);
test(
"%3.2g",
"9.9e-06",
0.0000099);
test(
"%3.0g",
"0.0001",
0.0001);
test(
"%3.0g",
"9e-05",
0.00009);
test(
"%3.0g",
"0.0001",
0.000099);
test(
"%3.1g",
"0.0001",
0.000099);
test(
"%3.2g",
"9.9e-05",
0.000099);
test(
"%3.0g",
"0.001",
0.001);
test(
"%3.0g",
"0.001",
0.00099);
test(
"%3.1g",
"0.001",
0.00099);
test(
"%3.2g",
"0.00099",
0.00099);
test(
"%3.3g",
"0.00100",
0.001);
test(
"%3.4g",
"0.001000",
0.001);
test(
"%3.0g",
"0.01",
0.01);
test(
"%3.0g",
"0.1",
0.1);
test(
"%3.0g",
"0.9",
0.9);
test(
"%3.1g",
"0.9",
0.9);
test(
"%3.0g",
" 1",
1.00);
test(
"%3.2g",
" 10",
10.00);
test(
"%3.0g",
"1e+01",
10.00);
test(
"%3.0g",
"1e+02",
99.19);
test(
"%3.1g",
"1e+02",
99.19);
test(
"%3.2g",
" 99",
99.19);
test(
"%3.0g",
"1e+02",
99.9);
test(
"%3.1g",
"1e+02",
99.9);
test(
"%3.2g",
"1.0e+02",
99.9);
test(
"%3.0g",
"1e+02",
99.99);
test(
"%3.0g",
"1e+02",
100.00);
test(
"%3.0g",
"1e+03",
999.9);
test(
"%3.1g",
"1e+03",
999.9);
test(
"%3.2g",
"1.0e+03",
999.9);
test(
"%3.3g",
"1.00e+03",
999.9);
test(
"%3.4g",
"999.9",
999.9);
test(
"%3.4g",
"1000",
999.99);
test(
"%3.0g",
"1e+03",
1000.00);
test(
"%3.0g",
"1e+04",
10000.00);
test(
"%3.0g",
"1e+05",
100000.00);
test(
"%3.0g",
"1e+06",
1000000.00);
test(
"%3.0g",
"1e+07",
10000000.00);
test(
"%3.9g",
"100000000",
100000000.00);
test(
"%3.10g",
"100000000.0",
100000000.00);
// = 13962455701329742638131355433930076081862072808 ... e+149 test(
"%+10.3g",
" +3.14",
pi);
test(
"%(.4g",
"3.142e+08",
mult(
pi,
100000000.0));
test(
"%(.4g",
"(3.142e+08)",
mult(
pi, -
100000000.0));
test(
"%,.11g",
"3,141,592.6536",
mult(
pi,
1000000.0));
test(
"%(,.11g",
"(3,141,592.6536)",
mult(
pi, -
1000000.0));
//--------------------------------------------------------------------- // Floating-point conversions applicable to float, double, and //--------------------------------------------------------------------- test(
"%.11a",
"0x0.00000000000p0",
0.0);
test(
"%.1a",
"0x0.0p0",
0.0);
test(
"%.11a",
"-0x0.00000000000p0", -
0.0);
test(
"%.1a",
"-0x0.0p0", -
0.0);
test(
"%.11a",
"0x1.00000000000p0",
1.0);
test(
"%.1a",
"0x1.0p0",
1.0);
test(
"%.11a",
"-0x1.00000000000p0", -
1.0);
test(
"%.1a",
"-0x1.0p0", -
1.0);
test(
"%.11a",
"0x1.80000000000p1",
3.0);
test(
"%.1a",
"0x1.8p1",
3.0);
test(
"%.11a",
"0x1.00000000000p-1022",
test(
"%.1a",
"0x1.0p-1022",
test(
"%.11a",
"0x1.ffffffffffep-1023",
test(
"%.1a",
"0x1.0p-1022",
test(
"%.11a",
"0x1.08000000000p-1069",
test(
"%.1a",
"0x1.0p-1069",
test(
"%.11a",
"0x1.18000000000p0",
test(
"%.11a",
"0x1.28000000000p0",
//--------------------------------------------------------------------- // %f, %e, %g, %a - Boundaries //--------------------------------------------------------------------- //--------------------------------------------------------------------- // %f, %e, %g, %a - Double.MIN_VALUE //--------------------------------------------------------------------- test(
"%30.350f",
"0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000490000000000000000000000000",
//--------------------------------------------------------------------- // %f, %e, %g, %a - Double.MAX_VALUE //--------------------------------------------------------------------- test(
"%f",
"179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000",
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",
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)",
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",
test(
"%30.13f",
"179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000000000000",
test(
"%30.20f",
"179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00000000000000000000",
//--------------------------------------------------------------------- // Date/Time conversions applicable to Calendar, Date, and long. //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- // perhaps an IllegalFormatArgumentIndexException should be defined?