< prev index next >

test/java/util/Formatter/BasicCharObject.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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 
  40 
  41 
  42 import static java.util.Calendar.*;
  43 
  44 
  45 
  46 
  47 
  48 public class BasicCharObject 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         f = new Formatter(new StringBuilder(), Locale.US);
  56         f.format("foo " + fs + " bar", args);
  57         ck(fs, "foo " + exp + " bar", f.toString());
  58     }
  59 
  60     private static void test(Locale l, String fs, String exp, Object ... args)
  61     {


 505         //---------------------------------------------------------------------
 506         test("%h", Integer.toHexString("Hello, Duke".hashCode()),
 507              "Hello, Duke");
 508         test("%10h", "  ddf63471", "Hello, Duke");
 509         test("%-10h", "ddf63471  ", "Hello, Duke");
 510         test("%-10H", "DDF63471  ", "Hello, Duke");
 511         test("%10h", "  402e0000", 15.0);
 512         test("%10H", "  402E0000", 15.0);
 513 
 514         //---------------------------------------------------------------------
 515         // %h - errors
 516         //---------------------------------------------------------------------
 517         tryCatch("%#h", FormatFlagsConversionMismatchException.class);
 518 
 519         //---------------------------------------------------------------------
 520         // flag/conversion errors
 521         //---------------------------------------------------------------------
 522         tryCatch("%F", UnknownFormatConversionException.class);
 523 
 524         tryCatch("%#g", FormatFlagsConversionMismatchException.class);




 525 
 526 
 527 
 528 
 529 
 530 
 531 
 532 
 533 
 534 
 535 
 536 
 537 
 538 
 539 
 540 
 541 
 542 
 543 
 544 


   1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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 BasicCharObject 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         f = new Formatter(new StringBuilder(), Locale.US);
  53         f.format("foo " + fs + " bar", args);
  54         ck(fs, "foo " + exp + " bar", f.toString());
  55     }
  56 
  57     private static void test(Locale l, String fs, String exp, Object ... args)
  58     {


 502         //---------------------------------------------------------------------
 503         test("%h", Integer.toHexString("Hello, Duke".hashCode()),
 504              "Hello, Duke");
 505         test("%10h", "  ddf63471", "Hello, Duke");
 506         test("%-10h", "ddf63471  ", "Hello, Duke");
 507         test("%-10H", "DDF63471  ", "Hello, Duke");
 508         test("%10h", "  402e0000", 15.0);
 509         test("%10H", "  402E0000", 15.0);
 510 
 511         //---------------------------------------------------------------------
 512         // %h - errors
 513         //---------------------------------------------------------------------
 514         tryCatch("%#h", FormatFlagsConversionMismatchException.class);
 515 
 516         //---------------------------------------------------------------------
 517         // flag/conversion errors
 518         //---------------------------------------------------------------------
 519         tryCatch("%F", UnknownFormatConversionException.class);
 520 
 521         tryCatch("%#g", FormatFlagsConversionMismatchException.class);
 522 
 523 
 524 
 525 
 526 
 527 
 528 
 529 
 530 
 531 
 532 
 533 
 534 
 535 
 536 
 537 
 538 
 539 
 540 
 541 
 542 
 543 
 544 
 545 


< prev index next >