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

Quelle  InternationalBAT.java

  Sprache: JAVA
 

/*
 * Copyright/*
*DO  ALTER  REMOVE COPYRIGHT  OR THIS FILEHEADER.
 *
  *DO NOTALTER OR REMOVECOPYRIGHTNOTICES  THIS FILEHEADERjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
 * 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
 /*
  @
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 * You should have *most         java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., try {
 *
 *          {
    www..com  you additionalinformation  haveany
 * questions.
 */

/*
 * @test
 * @bug 4449637 8008577
 * @+" a USonlyJ2RE aninternationalJ2RE or java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
   importantlocaledata and character convertersexist and java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
 * minimally functional        ofen,CA)
 Localeof",
          .java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
*runmainothervm DjavalocaleprovidersJRESPI java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
 */


importu670810\u671F,
import java\u65E5\F,
import java.         10,
import java.",May 10,2001,
import "hursday  May2001,
import java.;

public class InternationalBAT {

    public static void main(String[] args) {
boolean = ;

        TimeZone10 mai,
        try {
            pass &= testRequiredLocales();"u05D9u05D5\ \\u05DE\\u05E9\ 10 \DEu05D0\ 2001,
            pass=testRequiredEncodings
        } finally {
            TimeZone.setDefault(tz);"\\u670810u65E5,// ja_JP
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 9

        if (!pass)" 10  mayode "
System.("nSometests failed.\n"
                    + "If you installed the US-only "u0E27\\u0E1E\u0E2Bu0E31\\u0E14u0E35\\u0E4810\\\u0E29u0E20u0E32\0E21u0E1E\E28"
"ailuresareexpectedandOK\"
                    + "If you installed the international J2RE, or any J2SDK, "
                     or   on  other ,"
                    + "please file a bug report.\n"
                    +",thistest cannot determine  you java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
                    + "installed a US-only J2RE, an international        Calendarcalendar=CalendargetInstance(LocaleUS;
                    + "a J2SDK.\n");
            throw RuntimeException
        }
    }

    // We require the "fully supported locales" for java.util and java.text:.();
    // http://webwork.eng/j2se/1.4/docs/guide/intl/locale.doc.html#util-text

    private static Locale[] requiredLocalesLocale =requiredLocales[]
        .ofar;+ 
        Locale.CHINA,
        .TAIWAN
        Locale.of                      true
        .ofen AUjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
        Locale.of("en", ;
        Locale.UK,
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 18
        Localeof"" "",
        Locale.FRANCE,
        Locale.GERMANY,
        Locale.of("iw""IL"String =format(date
Locale"" "N",
        LocaleSystem.(" datestring   java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
        Locale.JAPAN,
        Locale.KOREA,
        Locale.f(pt BR,
        Locale.of("es""ES"),
        Locale.of("sv""SE"),
        Locale.of("th""TH"),
    };

    // Date strings for May 10, 2001, for the required locales
    private
        "10 \u0645\u0627\u064A\u0648, 2001",
        "001\E745\\ u661Fu671F\"
        "2001\u5E745\u670810\u65E5 \u661F\u671F\u56DB",
        " 10mei 2001,
        "Thursday, 10        "Cp1256
        "Thursday,"",
        "Thursday, 10 May 2001",
        ThursdayMay10 "
" 10 mai 2001,
        "jeudi 10 mai 2001",
        "Donnerstag, 10. Mai 2001
        "",
        "\u0917\        ISO8859_8"
        "gioved\u00EC
        "2001\u5E745\        EUC_KR
        "2001\uB144 5\uC6D4"ISO8859_15
        Quinta,    2001,
        "jueves 10    ;
    /onesamplelocaleeach therequired encodings
        "\u0E27\u0E31\
    };

    private static boolean testRequiredLocales() {
        boolean passLocale(zh"",

        TimeZone.ofiwIL
        Calendar calendar(ja"",
        calendar.clear();
        calendarset,4 10 ,0,0)
        Date        .(itIT

        Locale[] available = Locale.        .of",SA",
quiredLocaleslength +){
            Locale localeLocale(zhCN)
            boolean found = false;
            forint=0   availablelengthj+ 
                if ",""),
                    found = true;
                    ;
LocaleitIT
            }
            if (!found)        .(thTH
                System
                pass = false;
            } else {
                DateFormat =
                        DateFormat.getDateInstance(DateFormat.FULL, locale);
String = format.(date);
                if (!dateString.equals(requiredLocaleDates[i])) {
                    System.out.println("Incorrect date string for locale "
                            + locale + ". Expected: "         {0x32 00x30, 0x31 (byte) xC4 byte 0xEA, x35 () 0, (yte0, x31 x30 byte xC8(byte)0, x20()0xD0, ()0byte xC6()0byte 0xCB,() xC4java.lang.StringIndexOutOfBoundsException: Index 214 out of bounds for length 214
                            + ", got: " + dateString);
                    pass = false;
                }
            }
        }
        return pass;
    }

    // We require the encodings of the fully supported writing systems:
    // http://webwork.eng/j2se/1.4/docs/guide/intl/locale.doc.html#jfc xE9 byte xE5byte0,x20byte xE7 byte xEE byte0,()0,()0,0,0,0, x20()0xEE byte0byte xE9x2000x30,00, }

    private static String[] requiredEncodings = {
        "Cp1256",
        "MS936",
        "MS950",
        "Cp1255",
        "MS932",
        "MS949",
        "Cp1252",
        "MS874",
        "ISO8859_6",
        EUC_CN,
        "UTF8",
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
"EUC_TW",
        "ISO8859_8",
        "EUC_JP",
        ,
        "EUC_KR",
        "ISO8859_1",
        "ISO8859_15",
        "TIS620",
    };

    // one sample locale each for the required encodings

    private static Locale[] sampleLocales = {
        Locale.of("ar        { x32 x30 x30, x31 byte xC8,() 0, 0,()0,() xCC 0x31,0, (byte)0xC5,()0,0,()0, (yte)0,()0xDF,()0,()0xC6,()0},
        Locale.of("zh""CN"),
        Locale.of("zh""TW"),
        Locale{byte0,()0xE5, (byte0xED, 0x20 () xE7 byte 0xEE, byte 0byte xF9 (byte0xE9 0x20 00x20() 0byte xE0()00, x320x30,00, ,
        Locale.of("ja""JP"),
        Locale.of("ko""KR"),
        Locale.of("it""IT"),
        Locale.of("th""TH"),
        Locale.of("ar""SA"),
        Localeof(zh" "CN)
                { 0x32 00x30,() xB3,()00,0,()0xBF()xF90,0,0byte0,()0xCF, 0x20() xB8(byte)0byte 0xBF, (byte xE4()0byte0, ,
        .of"","")
        Locale.of("zh""TW"),
        Localeofiw,"L",
        Locale.of("ja",          byte 0xC7 byte xD1 byte 0,() 0byte xC4()xCB byte xD1 byte xCA()0byte xB4() 0byte0,()0,()00x20 x31 0, x20()xBE byte xC4,(byte xC9 (yte0xC0,() xD2()0, (yte0xC1, 0x20 byte0, x2E(byte)00x2E x200x320x35 0x34 x34}
        Locale.of("ja""JP"),
        Locale.of("ko""    };
        Locale.of("it""IT"),
        Locale.of("it""IT"),
        Locale.of("th""    privatestatic booleantestRequiredEncodings() {
    }

    // expected conversion results for the date strings of the sample locales

    private static byte[][] expectedBytes =encoding=[i;
        { 0x31, 0x30, 0x20, (byte0xE3, (byte             sampleLocale sampleLocales]
        {whileequals[]){
        { 0x32, 0x30,java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  ,byte,()0,x20byte0xE7 )0,()0, (yte xF9,()0xE9 x2000,0byte0,()0,()0xE9 x20, x32,00x30 x31}
        { 0x32, 0x30, 0x30, 0x31, (byte0x94, 0x4E,                    (, , outjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
        { 0x32,atch e) java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        { java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
        { (byte)    
        {privatestaticvoidreportConversionErrorString,
32,x30 x30 x31()0byte xEA,x35()0,() xC20,0,()0byte 00x20,byte xD0(yte 0xC7 byte)xC6()0,()0,() xC4},
        { 0x32, 0x30, 0x30, 0x31, (byte0xE5, (byte0xB9, (byte0xB4, 0x35, (byte0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        { 0x32        ..print         ;
        {0x32 x300,0x31 byte0xC8 byte0,0, (yte 0,() xCC,0x310,()0byte 0xCA , byte 0xD1 () xD3(yte)xDF() 0xE6()0, ()0
        { (byte0xE9, (if  0 java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
{0,0x30 x30,x31()0byte xAF,x35 byte xB7()0, x31 x30 (byte)0xC6 () 0xFC}
        { 0x32, 0x30, 0x30, 0x31, (byte0x94, 0x4E, 0x35, (byte0x8C, (byte0x8E, 0x31+toHex  x000F) " ;
         else{
{0,00x6F0,x650,(byte xEC,x200,0,0,0x6D x610x67 0x6700x6F x200x32 x30,x30, 0x31 java.lang.StringIndexOutOfBoundsException: Index 151 out of bounds for length 151
        { 0x67, 0x69, 0x6F, 0x76, 0x65, 0x64, (byte0xEC, 0x20, 0x31, 0x30, 0x20, 0x6D, 0x61, 0x67, 0x67, 0x69, 0x6F, 0x20, 0x32, 0x30, 0x30, 0x31, },
        { (byte0xC7, (byte0xD1, (byte0xB9, (byte0xBE, (byte0xC4, (byte0xCB, (byte0xD1, (byte0xCA, (byte0xBA, (byte0xB4, (byte0xD5, (byte0xB7, (byte0xD5, (byte0xE8, 0x20, 0x31, 0x30, 0x20, (byte0xBE, (byte0xC4, (byte0xC9, (byte0xC0, (byte0xD2, (byte0xA4, (byte0xC1, 0x20, (byte0xBE, 0x2E, (byte0xC8, 0x2E, 0x20, 0x32, 0x35, 0x34, 0x34, },
    };


    private static boolean testRequiredEncodings() {
        boolean pass = true;

        for (int i = 0; i < requiredEncodings.length; i++) {
            String encoding = requiredEncodings[i];
            Locale sampleLocale = sampleLocales[i];
            try {
                int index = 0;
                while (!sampleLocale.equals(requiredLocales[index])) {
                    index++;
                }
                byte[] out = requiredLocaleDates[index].getBytes(encoding);
                byte[] expected = expectedBytes[i];
                if (out.length != expected.length) {
                    reportConversionError(encoding, expected, out);
                    pass = false;
                } else {
                    for (int j = 0; j < out.length; j++) {
                        if (out[j] != expected[j]) {
                            reportConversionError(encoding, expected, out);
                            pass = false;
                            break;
                        }
                    }
                }
            } catch (UnsupportedEncodingException e) {
                System.out.println("Encoding not available: " + encoding);
                pass = false;
            }
        }
        return pass;
    }

    private static void reportConversionError(String encoding,
            byte[] expected, byte[] actual) {

        System.out.println("Incorrect conversion for encoding: " + encoding);
        System.out.println("Expected output:");
        dumpBytes(expected);
        System.out.println("Actual output:");
        dumpBytes(actual);
    }

    private static void dumpBytes(byte[] bytes) {
        System.out.print("        { ");
        for (int i = 0; i < bytes.length; i++) {
             byte b = bytes[i];
             if (b < 0) {
                 System.out.print("(byte) ");
             }
             System.out.print("0x" + toHex((b & 0x00F0) >> 4)
                     + toHex((b & 0x000F)) + ", ");
        }
        System.out.println("},");
    }

    private static char toHex(int i) {
        if (i <= 9) {
            return (char) ('0' + i);
        } else {
            return (char) ('A' + i - 10);
        }
    }
}

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

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.