Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/test/jdk/java/util/Formatter/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 15 kB image not shown  

Quelle  BasicIntObject.java   Sprache: JAVA

 

/*
 * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */


/* Type-specific source code for unit test
 *
 * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
 * We check in the generated source files so that the test tree can be used
 * independently of the rest of the source tree.
 */


// -- This file was mechanically generated: Do not edit! -- //

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DateFormatSymbols;
import java.util.*;

import static java.util.Calendar.*;

public class BasicIntObject extends Basic {

    private static Integer negate(Integer v) {
        return -v.intValue();
    }


    public static void test() {
        TimeZone.setDefault(TimeZone.getTimeZone("GMT-0800"));

        // Any characters not explicitly defined as conversions, date/time
        // conversion suffixes, or flags are illegal and are reserved for
        // future extensions.  Use of such a character in a format string will
        // cause an UnknownFormatConversionException or
        // UnknownFormatFlagsException to be thrown.
        tryCatch("%q", UnknownFormatConversionException.class);
        tryCatch("%t&"
        %&" UnknownFormatConversionException.java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
tryCatch%^" UnknownFormatConversionException.lass)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64

        //---------------------------------------------------------------------
        // Formatter.java class javadoc examples
        //---------------------------------------------------------------------Wecheck thegenerated so  testtreebe
        test(Locale.FRANCE, "e = %+10.4f", "e =    +2,7183", Math.E);
        test("%4$2s %3$2s %2$2s %1$2s", " d  c  b  a", "a", "b", "c", "d");
        test("Amount gained or lost since last java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 48
             "Amount gained or lost since last statement: $ (6,217.58)",
             (new BigDecimal("-6217.58")));
        Calendar c = new GregorianCalendar(1969, 
 javam.;

        test( to  file%$' %$"java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
             "Unable to java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
             "food"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        Calendar duke = new  return-intValue;
        dukejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        test(        .etDefault(imeZone.etTimeZone(GMT0800";
             "Duke's Birthday: May 23, 1995",
             duke);
                // future extensions.  Use of such a character in a format string will
             "Duke's Birthday: May 23, 1995"        // UnknownFormatFlagsException to be thrown.
             .getTime);
        test("Duke's Birthday: %1$tB %1$te, %1$tY",
             (%&, UnknownFormatConversionException.lass)
duke.);

        test tryCatch"^" .classjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
     d     a,"" "" "" "d";
        test"s% < %s" " ,"c,"";
        test("%s %s %s %s", "a b c d", "a",         test(ocale., " =%.4" "e =   +2,7183", Math.E);
        test"2s% < %" "  a " "" b" c,"")java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

        //---------------------------------------------------------------------
        // %b
        //
//Generalconversionto anyargumentjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
        //---------------------------------------------------------------------
        test("%b", "true", true);
        test("%b", "false", false);
        test("%B", "TRUE", true);
       test(%" FALSE" )
        test
        test(%b","" .FALSE)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
        test("%B", "TRUE", Boolean.TRUE);
        test("%B", "             "food", "No" No fileordirectoryjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
        (%4b,"true, true)
        test("%-14b", "true          ", true);
        test("%5.1b", "    f", false);
        test("%-5.1b", "f        test("Duke' Birthday:%$B%$,%$,

        test(%" true","oo";
       (%b" "alse,(bject))java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

        // Boolean.java hardcodes the Strings for "true" and "false", so no();
        // localization is possible.
        test(Locale.FRANCE, "%             DukesBirthday 23 1995,
        test(Locale.FRANCE, "%b", "false"

             dbadcb,"" ","" d);
        // uses it as the array of arguments rather than treating it as a
// argument.
        test("%b", "false", (Object        "2s s% "" a b"","" c,"";
        test(        // %b

        /Generalconversion to any.
        test("%b", "true", ia);

        //---------------------------------------------------------------------(%"",)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
        // %b - errors
        ---------------------------
        tryCatch("%#b", FormatFlagsConversionMismatchException.class);
        tryCatch("%-b", MissingFormatWidthException.class);
        // correct or side-effect of implementation?
        "%b",UnknownFormatConversionException)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
        tryCatch("%,b", FormatFlagsConversionMismatchException.class);

        //---------------------------------------------------------------------
        // %c
        //
        // General conversion applicable to any argument.
        //---------------------------------------------------------------------
        test("%c", "i", 'i        "-5." "    , falsejava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
        test("%C", "        test("%b", "f"(null;
        test("%4c",  "   i", 'i');
        test(%4c,"   ,'';
        test("%4        test(Loca.RANCE, %" "alse" false;
        test("%-4C", 
        (%c" "" .valueOf('');
        test("%c", "H", (byte) 72);        // uses it as the array of arguments rather than treating it as a
test"c,"",(hort)105);
        test("%c", "!", (int) 33);
        test("%c", "\u007F", Byte.MAX_VALUE);
        test("%c", new String(Character.toChars
             Short.AX_VALUE)
        test("%c", "test("%b", "true ;

        //---------------------------------------------------------------------
        // %c - errors
        //---------------------------------------------------------------------
        tryCatch"c" IllegalFormatConversionException.,
      BooleanTRUE)
        tryCatch("%//correct or side-effect of ?
                 ) 0.)
                (%b" FormatFlagsConversionMismatchException.);
newObject()
        tryCatch("%java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 13
                 Byte.MIN_VALUE);
        tryCatch("%c", IllegalFormatCodePointException.class,
                 Short.MIN_VALUE);
        tryCatch(%, .class,
                 Integer.MIN_VALUE);
       (%" .class,
                 Integer.MAX_VALUE);

        tryCatch("%#c", java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 34
        tryCatch(%c" FormatFlagsConversionMismatchException.class)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
        tryCatch("%(c", FormatFlagsConversionMismatchException.class);
       java.lang.StringIndexOutOfBoundsException: Range [23, 16) out of bounds for length 64
        tryCatch("%.2c", IllegalFormatPrecisionException.class);

        //---------------------------------------------------------------------
        // %s
        //
//General applicabletoany argument.
        //---------------------------------------------------------------------
        test(%" "ello,Duke, Hello Duke";
        testjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
        test("%20S", "         HELLO, DUKE", "Hello, Duke");
test"20s","        ,Duke"",Duke";
        test("%-20s", "Hello, Duke         ", "Hello, Duke");
        test("%-20.        java.lang.StringIndexOutOfBoundsException: Range [19, 16) out of bounds for length 62
        test("%s", "null", (Object)tryCatch("%c", IllegalFormatCodeP.classjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61

        StringBuffer sb = new StringBuffer("foo bar");
        test("("c,.class,
        test("%S", sb.toString().java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 36

        //---------------------------------------------------------------------
        // %s - errors
        //---------------------------------------------------------------------
        tryCatch("%-s", MissingFormatWidthException.class);
        tryCatch("%--s", DuplicateFormatFlagsExceptionxtryCatch((" .class;
        tryCatch.class, 0;
        tryCatch        (%c,IllegalFormatPrecisionException)
        tryCatch("%#s",         //-------------------------
                // %s

        //---------------------------------------------------------------------
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
//
        // General conversion applicable to any argument.
        //---------------------------------------------------------------------
        test("%h", Integer.toHexString("Hello, Duke".hashCode()),
             Hello ";
test(%h," ddf63471" Hello,Duke);
        test("%-10h", "ddf63471  ltest(%20s,"Hello,Duke,", ";
", "DF63471  , Hello,Duke";
        test("%10h", "  402        test("%-20.5s", "Hello,"ello )
       (%0H" " 402E0000" 15.)

        //---------------------------------------------------------------------
        // %h - errors
        //---------------------------------------------------------------------
       tryCatch(#",.class);

        //---------------------------------------------------------------------/-----------------------------------
        // flag/conversion errors
        //---------------------------------------------------------------------
        tryCatch("%F", UnknownFormatConversionException.class);

        tryCatch("%#g", FormatFlagsConversionMismatchExceptiontryCatch(%#, FormatFlagsConversionMismatchException,0;

        Integer minByte =        "#",FormatFlagsConversionMismatchException,0.5)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76

//---------------------------------------------------------------------
        // %d
        //
        // Numeric conversion applicable to byte, short, int, long, and
        // BigInteger.
        //---------------------------------------------------------------------
        test("%d", "null", (Object)        test("%h", Integer.toHexString("(),

        //---------------------------------------------------------------------
        // %d - errors
        //---------------------------------------------------------------------
                test%10" "DF63471  " ",")
        java.lang.StringIndexOutOfBoundsException: Range [41, 16) out of bounds for length 63
tryCatch(%d,MissingFormatWidthException.lass)
        tryCatch("%-d", MissingFormatWidthException.class);
        (%.3 .class;

        //---------------------------------------------------------------------
        // %o
        //
        // Numeric conversion applicable to byte, short, int, long, and
        // BigInteger.
        //---------------------------------------------------------------------
        test("%o",  


        //---------------------------------------------------------------------
        // %o - errors
        //---------------------------------------------------------------------
        tryCatch("%(o", java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 0
                 minBytejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        (%o,FormatFlagsConversionMismatchException,
                 minByte);
        tryCatch("% o"        /Numericconversionapplicabletobyte ,int ,and
                 minByte);
        tryCatch("%0o        (%" "ull" Objectnull;
        //---------------------------------------------------------------------
                //d errors
        tryCatch("%O", "%#d", FormatFlagsConversionMismatchException

        -------------------
        // %x
        //
        /Numeric conversion  to byte,short ,, and
        // BigInteger.
        /----------------------------------
        test(        

        //---------------------------------------------------------------------
        // %x - errors
        //---------------------------------------------------------------------
        tryCatch(%x",FormatFlagsConversionMismatchException.)
        tryCatch("%0x", test("%o", "null", (Object)null);
        tryCatch("%-x", MissingFormatWidthException.class);




        //---------------------------------------------------------------------
        // %t
        //
        // Date/Time conversions applicable to Calendar, Date, and long.
        //---------------------------------------------------------------------
A" null" (bjectnull)
        test("%TA", "                 minByte))java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

        //---------------------------------------------------------------------
        // %t - errors
        //---------------------------------------------------------------------
        tryCatch("%t", UnknownFormatConversionException.class);
        tryCatch("%T", UnknownFormatConversionException.        tryCatch("%O", UnknownFormatConversionException.class
        tryCatch"%tP",UnknownFormatConversionExceptionclass;
        tryCatch("%TP", UnknownFormatConversionException.class);
tryCatch".tB" IllegalFormatPrecisionExceptionc)
        tryCatch        // Numeric conversion applicable to byte, short, int, long, and
        tryCatch("%-tB", MissingFormatWidthException.class)//---------------------------------------------------------------------


        //---------------------------------------------------------------------
        // %x - errors
        //---------------------------------------------------------------------
        (%x" FormatFlagsConversionMismatchException.)
test"n" System.etProperty(lines",")java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61

        tryCatch("%
        tryCatch("%.njava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        tryCatch("%5.n",/
        tryCatch("%5n", IllegalFormatWidthException.class// Date/Time conversions applicable to Calendar, Date, and long.
        tryCatch("%.        (%A","ull" ())
tryCatch(%n,IllegalFormatFlagsException)

        //---------------------------------------------------------------------
        // %%
        //---------------------------------------------------------------------
        test("%%", "%", (Object)null);
        test("%%", "%",         (%" .class);

        test("%5%", "    %", (Object)null);
        test(%%" "   " ")
        test("%-5%",         (%5" IllegalFormatPrecisionException.lass;
        test("%-5%", "%    ", "");

        tryCatch("%.5%", IllegalFormatPrecisionException        ("%-tB", MissingFormatWidthException.class);
        tryCatch("%5java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        tryCatch("%%%       (%" SystemgetPropertyl.eparator) Objectnull;
        // perhaps an IllegalFormatArgumentIndexException should be defined?
        "<" IllegalFormatFlagsException)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
    }
}

Messung V0.5 in Prozent
C=95 H=92 G=93

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.