test/java/util/Formatter/BasicDouble.java

Print this page




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* Type-specific source code for unit test
  25  *
  26  * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
  27  * We check in the generated source files so that the test tree can be used
  28  * independently of the rest of the source tree.
  29  */
  30 
  31 // -- This file was mechanically generated: Do not edit! -- //
  32 
  33 import java.io.*;
  34 import java.math.BigDecimal;
  35 import java.math.BigInteger;
  36 import java.text.DateFormatSymbols;
  37 import java.util.*;
  38 
  39 import sun.misc.DoubleConsts;
  40 
  41 
  42 import static java.util.Calendar.*;
  43 
  44 
  45 
  46 
  47 
  48 public class BasicDouble extends Basic {
  49 
  50     private static void test(String fs, String exp, Object ... args) {
  51         Formatter f = new Formatter(new StringBuilder(), Locale.US);
  52         f.format(fs, args);
  53         ck(fs, exp, f.toString());
  54     }
  55 
  56     private static void test(Locale l, String fs, String exp, Object ... args)
  57     {
  58         Formatter f = new Formatter(new StringBuilder(), l);
  59         f.format(fs, args);
  60         ck(fs, exp, f.toString());
  61     }


1296 
1297 
1298         //---------------------------------------------------------------------
1299         // %a
1300         //
1301         // Floating-point conversions applicable to float, double, and
1302         // BigDecimal.
1303         //---------------------------------------------------------------------
1304         test("%a", "null", (Object)null);
1305         test("%.11a", "0x0.00000000000p0", 0.0);
1306         test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
1307         test("%.1a", "0x0.0p0", 0.0);
1308         test("%.11a", "-0x0.00000000000p0", -0.0);
1309         test("%.1a", "-0x0.0p0", -0.0);
1310         test("%.11a", "0x1.00000000000p0", 1.0);
1311         test("%.1a", "0x1.0p0", 1.0);
1312         test("%.11a", "-0x1.00000000000p0", -1.0);
1313         test("%.1a", "-0x1.0p0", -1.0);
1314         test("%.11a", "0x1.80000000000p1", 3.0);
1315         test("%.1a", "0x1.8p1", 3.0);
1316         test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
1317         test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
1318         test("%.11a", "0x1.00000000000p-1022",
1319              Math.nextDown(DoubleConsts.MIN_NORMAL));
1320         test("%.1a", "0x1.0p-1022",
1321              Math.nextDown(DoubleConsts.MIN_NORMAL));
1322         test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
1323         test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);
1324         test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
1325         test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1326         test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
1327         test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
1328 
1329         test("%.11a", "0x1.08000000000p-1069",
1330              Double.MIN_VALUE + Double.MIN_VALUE*32);
1331         test("%.1a", "0x1.0p-1069",
1332              Double.MIN_VALUE + Double.MIN_VALUE*32);
1333         test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
1334         test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1335         test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1336         test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
1337         test("%.11a", "0x1.18000000000p0", 0x1.18p0);
1338         test("%.1a", "0x1.2p0", 0x1.18p0);
1339 
1340         test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0);
1341         test("%.1a", "0x1.2p0", 0x1.180000000001p0);




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* Type-specific source code for unit test
  25  *
  26  * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
  27  * We check in the generated source files so that the test tree can be used
  28  * independently of the rest of the source tree.
  29  */
  30 
  31 // -- This file was mechanically generated: Do not edit! -- //
  32 
  33 import java.io.*;
  34 import java.math.BigDecimal;
  35 import java.math.BigInteger;
  36 import java.text.DateFormatSymbols;
  37 import java.util.*;
  38 



  39 import static java.util.Calendar.*;
  40 
  41 
  42 
  43 
  44 
  45 public class BasicDouble extends Basic {
  46 
  47     private static void test(String fs, String exp, Object ... args) {
  48         Formatter f = new Formatter(new StringBuilder(), Locale.US);
  49         f.format(fs, args);
  50         ck(fs, exp, f.toString());
  51     }
  52 
  53     private static void test(Locale l, String fs, String exp, Object ... args)
  54     {
  55         Formatter f = new Formatter(new StringBuilder(), l);
  56         f.format(fs, args);
  57         ck(fs, exp, f.toString());
  58     }


1293 
1294 
1295         //---------------------------------------------------------------------
1296         // %a
1297         //
1298         // Floating-point conversions applicable to float, double, and
1299         // BigDecimal.
1300         //---------------------------------------------------------------------
1301         test("%a", "null", (Object)null);
1302         test("%.11a", "0x0.00000000000p0", 0.0);
1303         test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
1304         test("%.1a", "0x0.0p0", 0.0);
1305         test("%.11a", "-0x0.00000000000p0", -0.0);
1306         test("%.1a", "-0x0.0p0", -0.0);
1307         test("%.11a", "0x1.00000000000p0", 1.0);
1308         test("%.1a", "0x1.0p0", 1.0);
1309         test("%.11a", "-0x1.00000000000p0", -1.0);
1310         test("%.1a", "-0x1.0p0", -1.0);
1311         test("%.11a", "0x1.80000000000p1", 3.0);
1312         test("%.1a", "0x1.8p1", 3.0);
1313         test("%.11a", "0x1.00000000000p-1022", Double.MIN_NORMAL);
1314         test("%.1a", "0x1.0p-1022", Double.MIN_NORMAL);
1315         test("%.11a", "0x1.00000000000p-1022",
1316              Math.nextDown(Double.MIN_NORMAL));
1317         test("%.1a", "0x1.0p-1022",
1318              Math.nextDown(Double.MIN_NORMAL));
1319         test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
1320         test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);
1321         test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
1322         test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1323         test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
1324         test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
1325 
1326         test("%.11a", "0x1.08000000000p-1069",
1327              Double.MIN_VALUE + Double.MIN_VALUE*32);
1328         test("%.1a", "0x1.0p-1069",
1329              Double.MIN_VALUE + Double.MIN_VALUE*32);
1330         test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
1331         test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1332         test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1333         test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
1334         test("%.11a", "0x1.18000000000p0", 0x1.18p0);
1335         test("%.1a", "0x1.2p0", 0x1.18p0);
1336 
1337         test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0);
1338         test("%.1a", "0x1.2p0", 0x1.180000000001p0);