products/Sources/formale Sprachen/Java/Openjdk/test/jdk/java/lang/ProcessHandle/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 20 kB image not shown  

Quelle  BasicShort.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 BasicShort extends Basic {

    private static short negate(short v) {
        return (short) -v;
    }


    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.class);
        tryCatch("%&d", UnknownFormatConversionException.class);
        tryCatch("%^b", UnknownFormatConversionException.class);

        //---------------------------------------------------------------------
        // Formatter.java class javadoc examples
        //---------------------------------------------------------------------
        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 statement: $ %,(.2f",
             "Amount gained or lost since last statement: $ (6,217.58)",
             (new BigDecimal("-6217.58")));
        Calendar c = new GregorianCalendar(1969, JULY, 2016170);
        testSysOut("Local time: %tT""Local time: 16:17:00", c);

        test("Unable to open file '%1$s': %2$s",
             "Unable to open file 'food': No such file or directory",
             "food""No such file or directory");
        Calendar duke = new GregorianCalendar(1995, MAY, 23194834);
        duke.set(Calendar.MILLISECOND, 584);
        test("Duke's Birthday: %1$tB %1$te, %1$tY",
             "Duke's Birthday: May 23, 1995",
             duke);
        test("Duke's Birthday: %1$tB %1$te, %1$tY",
             "Duke's Birthday: May 23, 1995",
             duke.getTime());
        test("Duke's Birthday: %1$tB %1$te, %1$tY",
             "Duke's Birthday: May 23, 1995",
             duke.getTimeInMillis());

        test("%4$s %3$s %2$s %1$s %4$s %3$s %2$s %1$s",
             "d c b a d c b a""a""b""c""d");
        test("%s %s %<s %<s""a b b b""a""b""c""d");
        test("%s %s %s %s""a b c d""a""b""c""d");
        test("%2$s %s %<s %s""b a a b""a""b""c""d");

        //---------------------------------------------------------------------
        // %b
        //
        // General conversion applicable to any argument.
        //---------------------------------------------------------------------
        test("%b""true"true);
        test("%b""false"false);
        test("%B""TRUE"true);
        test("%B""FALSE"false);
        test("%b""true"Boolean.TRUE);
        test("%b""false"Boolean.FALSE);
        test("%B""TRUE"Boolean.TRUE);
        test("%B""FALSE"Boolean.FALSE);
        test("%14b""          true"true);
        test("%-14b""true          "true);
        test("%5.1b""    f"false);
        test("%-5.1b""f    "false);

        test("%b""true""foo");
        test("%b""false", (Object)null);

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

        // If you pass in a single array to a varargs method, the compiler
        // uses it as the array of arguments rather than treating it as a
        // single array-type argument.
        test("%b""false", (Object[])new String[2]);
        test("%b""true"new String[2], new String[2]);

        int [] ia = { 123 };
        test("%b""true", ia);

        //---------------------------------------------------------------------
        // %b - errors
        //---------------------------------------------------------------------
        tryCatch("%#b", FormatFlagsConversionMismatchException.class);
        tryCatch("%-b", MissingFormatWidthException.class);
        // correct or side-effect of implementation?
        tryCatch("%.b", UnknownFormatConversionException.class);
        tryCatch("%,b", FormatFlagsConversionMismatchException.class);

        //---------------------------------------------------------------------
        // %c
        //
        // General conversion applicable to any argument.
        //---------------------------------------------------------------------
        test("%c""i"'i');
        test("%C""I"'i');
        test("%4c",  "   i"'i');
        test("%-4c""i   "'i');
        test("%4C",  "   I"'i');
        test("%-4C""I   "'i');
        test("%c""i", Character.valueOf('i'));
        test("%c""H", (byte72);
        test("%c""i", (short105);
        test("%c""!", (int33);
        test("%c""\u007F"Byte.MAX_VALUE);
        test("%c"new String(Character.toChars(Short.MAX_VALUE)),
             Short.MAX_VALUE);
        test("%c""null", (Object) null);

        //---------------------------------------------------------------------
        // %c - errors
        //---------------------------------------------------------------------
        tryCatch("%c", IllegalFormatConversionException.class,
                 Boolean.TRUE);
        tryCatch("%c", IllegalFormatConversionException.class,
                 (float0.1);
        tryCatch("%c", IllegalFormatConversionException.class,
                 new Object());
        tryCatch("%c", IllegalFormatCodePointException.class,
                 Byte.MIN_VALUE);
        tryCatch("%c", IllegalFormatCodePointException.class,
                 Short.MIN_VALUE);
        tryCatch("%c", IllegalFormatCodePointException.class,
                 Integer.MIN_VALUE);
        tryCatch("%c", IllegalFormatCodePointException.class,
                 Integer.MAX_VALUE);

        tryCatch("%#c", FormatFlagsConversionMismatchException.class);
        tryCatch("%,c", FormatFlagsConversionMismatchException.class);
        tryCatch("%(c", FormatFlagsConversionMismatchException.class);
        tryCatch("%$c", UnknownFormatConversionException.class);
        tryCatch("%.2c", IllegalFormatPrecisionException.class);

        //---------------------------------------------------------------------
        // %s
        //
        // General conversion applicable to any argument.
        //---------------------------------------------------------------------
        test("%s""Hello, Duke""Hello, Duke");
        test("%S""HELLO, DUKE""Hello, Duke");
        test("%20S""         HELLO, DUKE""Hello, Duke");
        test("%20s""         Hello, Duke""Hello, Duke");
        test("%-20s""Hello, Duke         ""Hello, Duke");
        test("%-20.5s""Hello               ""Hello, Duke");
        test("%s""null", (Object)null);

        StringBuffer sb = new StringBuffer("foo bar");
        test("%s", sb.toString(), sb);
        test("%S", sb.toString().toUpperCase(), sb);

        //---------------------------------------------------------------------
        // %s - errors
        //---------------------------------------------------------------------
        tryCatch("%-s", MissingFormatWidthException.class);
        tryCatch("%--s", DuplicateFormatFlagsException.class);
        tryCatch("%#s", FormatFlagsConversionMismatchException.class0);
        tryCatch("%#s", FormatFlagsConversionMismatchException.class0.5f);
        tryCatch("%#s", FormatFlagsConversionMismatchException.class"hello");
        tryCatch("%#s", FormatFlagsConversionMismatchException.class, (Object)null);

        //---------------------------------------------------------------------
        // %h
        //
        // General conversion applicable to any argument.
        //---------------------------------------------------------------------
        test("%h", Integer.toHexString("Hello, Duke".hashCode()),
             "Hello, Duke");
        test("%10h""  ddf63471""Hello, Duke");
        test("%-10h""ddf63471  ""Hello, Duke");
        test("%-10H""DDF63471  ""Hello, Duke");
        test("%10h""  402e0000"15.0);
        test("%10H""  402E0000"15.0);

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

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

        tryCatch("%#g", FormatFlagsConversionMismatchException.class);

        short minByte = Byte.MIN_VALUE;   // -128

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

        //---------------------------------------------------------------------
        // %d - short
        //---------------------------------------------------------------------
        short oneToFive = (short12345;
        test("%d""12345", oneToFive);
        test("%,d""12,345", oneToFive);
        test("%,d""-12,345", negate(oneToFive));
        test("%(d""12345", oneToFive);
        test("%(d""(12345)", negate(oneToFive));
        test("% d"" 12345", oneToFive);
        test("% d""-12345", negate(oneToFive));
        test("%+d""+12345", oneToFive);
        test("%+d""-12345", negate(oneToFive));
        test("%010d""0000012345", oneToFive);
        test("%010d""-000012345", negate(oneToFive));
        test("%(10d""   (12345)", negate(oneToFive));
        test("%-10d""12345     ", oneToFive);
        test("%-10d""-12345    ", negate(oneToFive));
        // , variations:
        test("% ,d"" 12,345", oneToFive);
        test("% ,d""-12,345", negate(oneToFive));
        test("%0,10d""000012,345", oneToFive);
        test("%0,10d""-00012,345", negate(oneToFive));
        test("%(,10d""  (12,345)", negate(oneToFive));
        test("%-,10d""12,345    ", oneToFive);
        test("%-,10d""-12,345   ", negate(oneToFive));

        //---------------------------------------------------------------------
        // %d - errors
        //---------------------------------------------------------------------
        tryCatch("%#d", FormatFlagsConversionMismatchException.class);
        tryCatch("%D", UnknownFormatConversionException.class);
        tryCatch("%0d", MissingFormatWidthException.class);
        tryCatch("%-d", MissingFormatWidthException.class);
        tryCatch("%7.3d", IllegalFormatPrecisionException.class);

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

        //---------------------------------------------------------------------
        // %o - short
        //---------------------------------------------------------------------

        test("%010o""0000177600", minByte);
        test("%-10o""177600    ", minByte);
        test("%#10o""   0177600", minByte);

        //---------------------------------------------------------------------
        // %o - errors
        //---------------------------------------------------------------------
        tryCatch("%(o", FormatFlagsConversionMismatchException.class,
                 minByte);
        tryCatch("%+o", FormatFlagsConversionMismatchException.class,
                 minByte);
        tryCatch("% o", FormatFlagsConversionMismatchException.class,
                 minByte);
        tryCatch("%0o", MissingFormatWidthException.class);
        tryCatch("%-o", MissingFormatWidthException.class);
        tryCatch("%,o", FormatFlagsConversionMismatchException.class);
        tryCatch("%O", UnknownFormatConversionException.class);

        //---------------------------------------------------------------------
        // %x
        //
        // Numeric conversion applicable to byte, short, int, long, and
        // BigInteger.
        //---------------------------------------------------------------------
        test("%x""null", (Object)null);

        //---------------------------------------------------------------------
        // %x - short
        //---------------------------------------------------------------------
        test("%010x""000000ff80", minByte);
        test("%-10x""ff80      ", minByte);
        test("%#10x""    0xff80", minByte);
        test("%0#10x","0x0000ff80", minByte);
        test("%#10X""    0XFF80", minByte);
        test("%X""FF80", minByte);
        //---------------------------------------------------------------------
        // %x - errors
        //---------------------------------------------------------------------
        tryCatch("%,x", FormatFlagsConversionMismatchException.class);
        tryCatch("%0x", MissingFormatWidthException.class);
        tryCatch("%-x", MissingFormatWidthException.class);




        //---------------------------------------------------------------------
        // %t
        //
        // Date/Time conversions applicable to Calendar, Date, and long.
        //---------------------------------------------------------------------
        test("%tA""null", (Object)null);
        test("%TA""NULL", (Object)null);

        //---------------------------------------------------------------------
        // %t - errors
        //---------------------------------------------------------------------
        tryCatch("%t", UnknownFormatConversionException.class);
        tryCatch("%T", UnknownFormatConversionException.class);
        tryCatch("%tP", UnknownFormatConversionException.class);
        tryCatch("%TP", UnknownFormatConversionException.class);
        tryCatch("%.5tB", IllegalFormatPrecisionException.class);
        tryCatch("%#tB", FormatFlagsConversionMismatchException.class);
        tryCatch("%-tB", MissingFormatWidthException.class);


        //---------------------------------------------------------------------
        // %n
        //---------------------------------------------------------------------
        test("%n", System.getProperty("line.separator"), (Object)null);
        test("%n", System.getProperty("line.separator"), "");

        tryCatch("%,n", IllegalFormatFlagsException.class);
        tryCatch("%.n", UnknownFormatConversionException.class);
        tryCatch("%5.n", UnknownFormatConversionException.class);
        tryCatch("%5n", IllegalFormatWidthException.class);
        tryCatch("%.7n", IllegalFormatPrecisionException.class);
        tryCatch("%<n", IllegalFormatFlagsException.class);

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

        test("%5%""    %", (Object)null);
        test("%5%""    %""");
        test("%-5%""%    ", (Object)null);
        test("%-5%""%    """);

        tryCatch("%.5%", IllegalFormatPrecisionException.class);
        tryCatch("%5.5%", IllegalFormatPrecisionException.class);

        tryCatch("%%%", UnknownFormatConversionException.class);
        // perhaps an IllegalFormatArgumentIndexException should be defined?
        tryCatch("%<%", IllegalFormatFlagsException.class);
    }
}

Messung V0.5 in Prozent
C=93 H=90 G=91

¤ 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.0.15Bemerkung:  (vorverarbeitet am  2026-06-10) ¤

*Bot Zugriff






Versionsinformation zu Columbo

Bemerkung:

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Anfrage:

Dauer der Verarbeitung:

Sekunden

sprechenden Kalenders