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 BasicLong 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 {
759 test("%x", "12d687", oneToSevenHex);
760 test("%010x", "000012d687", oneToSevenHex);
761 test("%-10x", "12d687 ", oneToSevenHex);
762 test("%#10x", " 0x12d687", oneToSevenHex);
763 test("%#10X", " 0X12D687",oneToSevenHex);
764 test("%X", "12D687", oneToSevenHex);
765
766 test("%018x", "00ffffffffffffff80", minByte);
767 test("%-18x", "ffffffffffffff80 ", minByte);
768 test("%#20x", " 0xffffffffffffff80", minByte);
769 test("%0#20x", "0x00ffffffffffffff80", minByte);
770 test("%#20X", " 0XFFFFFFFFFFFFFF80", minByte);
771 test("%X", "FFFFFFFFFFFFFF80", minByte);
772
773 //---------------------------------------------------------------------
774 // %x - errors
775 //---------------------------------------------------------------------
776 tryCatch("%,x", FormatFlagsConversionMismatchException.class);
777 tryCatch("%0x", MissingFormatWidthException.class);
778 tryCatch("%-x", MissingFormatWidthException.class);
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
|
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 BasicLong 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 {
756 test("%x", "12d687", oneToSevenHex);
757 test("%010x", "000012d687", oneToSevenHex);
758 test("%-10x", "12d687 ", oneToSevenHex);
759 test("%#10x", " 0x12d687", oneToSevenHex);
760 test("%#10X", " 0X12D687",oneToSevenHex);
761 test("%X", "12D687", oneToSevenHex);
762
763 test("%018x", "00ffffffffffffff80", minByte);
764 test("%-18x", "ffffffffffffff80 ", minByte);
765 test("%#20x", " 0xffffffffffffff80", minByte);
766 test("%0#20x", "0x00ffffffffffffff80", minByte);
767 test("%#20X", " 0XFFFFFFFFFFFFFF80", minByte);
768 test("%X", "FFFFFFFFFFFFFF80", minByte);
769
770 //---------------------------------------------------------------------
771 // %x - errors
772 //---------------------------------------------------------------------
773 tryCatch("%,x", FormatFlagsConversionMismatchException.class);
774 tryCatch("%0x", MissingFormatWidthException.class);
775 tryCatch("%-x", MissingFormatWidthException.class);
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
|