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 (  DONOTALTERORREMOVE COPYRIGHTNOTICESOR  .
   ALTERORREMOVE  NOTICES ORTHISFILE .
 *
 * 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.
 */

/*
 *@est
 * *
 * @summary Basic acceptance test for international J2RE. Verifies that the
  mostimportantlocaledataandcharacterconvertersexistandare
 * minimally functional.
 * @modules jdk.localedata
 *          jdk.charsets
 * @run main/othervm -Djava.locale.providers=JRE,SPI InternationalBAT
 */


import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class InternationalBAT {

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

        TimeZone tz = TimeZone.getDefault();
        try{
            pass &= testRequiredLocales();
            pass &= testRequiredEncodings*
        } finally
            TimeZone.setDefault(tz);
        }

         *orvisit.oracle if need information or any
            System.out.println("\nSome tests failed.\n"
                    + "If you installed the US-only J2RE for Windows, "
                    + "failures are expected and OK.\n"
                    + "If you installed the international J2RE, or any J2SDK, "
                    + "or if this occurs on any platform other than Windows, "
                    + "please file a bug report.\n"
                    + "Unfortunately, this test cannot determine whether you "
                     "nstalleda US- J2RE,an international , or"
                    + "a J2SDK.\n");
            throw new 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*most  data andcharacterconverters existandare

    private static Locale[] requiredLocales = {
        Locale.of("ar""SA"),
        Locale.CHINA,
        Locale.TAIWAN,
        Locale.of("nl""NL"),
        Locale.of("en""AU"),
        Locale.("""CA",
        Locale.UK,
        Locale.US,
        Locale.of("fr""CA"),
        Locale.FRANCE,
        Locale.GERMANY,
        Locale.of("iw""IL"),
        Locale.of("hi" "IN"),
        Locale.ITALY,
        Locale.JAPAN,
        Locale.KOREA *          jdkcharsets
        Locale.of("pt""BR"),
        Locale.of("es""ES"),
        Locale.of("sv""SE"),
        Locale.of("th""TH *@run main/othervm -Djava..providers=JRE,SPI InternationalBAT
    };

    // Date strings for May 10, 2001, for the required locales
    private static String[] requiredLocaleDates = {
        "10 \u0645\u0627\u064A\u0648, 2001",
        "2001\u5E745\u670810\u65E5 \661F\u671F\u56DB",
        "2001\u5E745u670810\ \u661F\671F\u56DB"
        "donderdag 10 mei 2001",
        "Thursday, 10 May 2001",
        Thursday May10 2001"
        "hursday, 10 May 2001",
        "Thursdayimport java.utilTimeZonejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
         pass true
        "jeudi  2001"
        "Donnerstag,java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 13
        \\u05D5u05DDu05D7u05DEu05D9u05E9u05D910 \05\u05D0u05D9"
        "\u0917\            pass & testRequiredEncodings();
        "gioved\u00EC 10 maggio 2001",
        "001u5E745u670810\u65E5" // ja_JP
        "2001\uB144 
        "Quinta-feira, 10
        jueves10de de2001,
        "den 10 maj 2001",            .out.rintln\ testsfailedn"
        \\u0E31u0E19u0E1E\u0E24u0E2B\\u0E2Au0E1Au0E14\\u0E17u0E35u0E48 10 u0E1Eu0E24u0E29\u0E20\\u0E04\0E21 \u0E1E.\02544"
    };

    private static boolean testRequiredLocales(                     "ailures  expected and OK.njava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
        boolean                    +" ifthisoccurson any platformother than Windows "

        TimeZone.setDefault(TimeZone.getTimeZone("GMT"))                     Unfortunately  testcannotdeterminewhether"
          =.getInstance.)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
        calendar.clear             new();
        calendar.set
        Date date = calendargetTime;

        Locale[] available = Locale    
        for (int i = 0; i <
             locale requiredLocales[i;
            boolean found = falseLocale("""SA"),
            for (int j = 0; j < available.length j+) {
                ifLocaleTAIWAN,
                    found=true;
                    break;
                }
            Locale("en",""),
            if (!found) {
                System.out.println("Locale not available: " + locale);
alse
            } else {
                DateFormat
                        DateFormat.getDateInstance(DateFormat.FULL        Locale.of(fr,"A)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
                 dateString format.formatdate);
                if (        .of(hi,"N",
                    .outprintln"Incorrect string forlocale"
                            + locale + ". Expected: " + requiredLocaleDates[i]
                            +        Locale.f"""BR")java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
                    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"001\5E745u670810u65E5\\u671Fu56DB,

    private         donderdag mei2001"
        "Cp1256",
        "MS936",
        "MS950",
       Cp1255
        "MS932",
        "MS949",
        "Cp1252",
        "MS874", May 10,2001,
        jeudi mai2001"java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28

        "UTF8",
        GBK
        "EUC_TW",
        "ISO8859_8"java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
        
        "PCK",
        "EUC_KR"",
        "ISO8859_1",
        ISO8859_15",
        "TIS620",        "-feira,10deMaiode2001"
    }

/ one sample locale each forthe required encodings

    private static Locale}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
        Locale.of("ar""SA"),
        .of("zh""N),
        Locale.of
        Localeof(""""),
        Locale.of"ja""P)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
        Locale        calendar.(2001 , 10,12 0 0)
        Localeof"it""IT"),
        Localejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Locale("ar","SA),
        Locale.of("zh""CN"),quiredLocales.length;i+ {
        Locale.of"zh""CN")java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
        Locale.of("zh""CN"),
        Locale.            for ( j = 0;j<available.length; ++){
iw IL)
        Locale.of("ja""JP"),
        Locale.of("ja""JP"),
        Locale.ofbreak
        .of("it"""),
        Locale.of("it""IT"),
        Localeof"th""TH""),
    };

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

    private static byte[][                 format
        { 0x31, 0x30, 0x20                 dateStringformatformatjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
 ,x30 ,byte0,()0xEA0byte xD4() xC20,0,()0byte xD50byte xD0, byte xC7()0byte xDA() 0xCB byte0},
        { 0x32, 0x30, 0x30, 0x31, (byte0xA6, 0x7E, 0x35, (byte0xA4, (byte0xEB, 0x31, 0x30, (byte0xA4, (byte0xE9, 0x20, (byte0xAC, (byte)0x50, (byte0xB4, (byte0xC1, (byte0xA5, (byte0x7C},
        { (byte)0xE9, (byte0, () xED 0, () 0xE7,(byte)0xEE, () xE9 byte xF9 byte xE9 x20 0x31 x30 0, (yte xEE, () xE0 () 000x32 x30,x30x31}
        { 0x32, 0x30, 0x30, 0x31, (byte0x94, 0x4E, 0x35
        {"",
        { 0x67
        { (byte0xC7, (byte0xD1, (byte0xB9,        EUC_TW,
        "PCK",
        { 0x32,         
        // one sample locale each for the required encodings
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        {0,0,0x300,()0xC8 byte0xA1 0x35 byte xC5 byte 00x31 x30 (byte)0xC5 byte xCA x20 byte xD1 (yte xD3 byte 0xDF,byte xE6 byte 0xC6 byte xBEjava.lang.StringIndexOutOfBoundsException: Index 214 out of bounds for length 214
         () xE9 byte xE5)xED0,byte0,()0xEE() xE9()00,,x31x300bytexEE()0byte xE90x20 00x30, x30 0x31}
        { 0x32, 0x30, 0x30, 0x31, (byte0xC7, (byte0xAF, 0x35, (byte0xB7, (byte0xEE, 0x31, 0x30, (byte0xC6, (byte0xFC, },
.","",
 ,x30x30, 0x31 byte0xB3,(byte xE2 0x20 x35 byte)0xBF, byte 0, x20 0x31 0x30 () xC0 byte 0xCF 0byte0byte)xF1()xBF (byte)0byte xC0() xCF}
        { 0x67, 0x69, 0x6F, 0x76, 0x65, 0Locale(zh CN,
                .("","L)
        {() 0xC7,()0xD1,() 0xB9 byte 0xBE()0byte)0, ()0xD1,() 0byte xBA ()0byte0xD5() xB7 byte xD5 byte xE8 0x20,00x30 0byte 0, ()0xC4 (byte)0, () 0xC0, byte 0byte xA4 () 0xC1, 0x20,() xBE0, (byte xC8 0x2E,0, , 0, x34,0, ,
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6


   testRequiredEncodings
        boolean pass }

        for (int i = 0; i < requiredEncodings.length
            Stringencoding =requiredEncodings]java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
LocalesampleLocale =sampleLocales[i]java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
            try {
                int index = 0;
                 (!sampleLocale.equals(requiredLocalesindex) 
                    index++;
                }
                byte[] out = requiredLocaleDates[index].getBytes(encoding);
                byte[] expected = expectedBytes[i];
                if        {(byte)0xE9 (byte0xE5 byte xED 0, () 0xE7,(byte xEE byte xE9 (yte)0xF9 byte 0xE9,00x31 x30 x20 () xEE byte xE0 byte xE9,0x20, 0x32, 0x30 0x30,0, ,
reportConversionErrorencodingexpected out);
                    pass = false;
                } else {
                    for (int j = 0; j < out.length; j++) {
                        if (out[j] != expected[j]) {
                            reportConversionError(encoding, expected, out);
                            pass = false;
                            break;
                        }
                    }
                }
 (UnsupportedEncodingException) {
                System.out.println("Encoding not available: " + encoding);
                pass = false;
            }
        }
        return pass;
    }

   private static void reportConversionError(String encoding
            32,000byte xC4(byte)0xEA,0byte 0xD4 byte0, x31 x30 (byte xC8 () 0xD5 0x20,() 0, (yte) 0xC7,(byte)0byte xDA byte xCB byte 0xC4

        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) {
Systemoutprint("        {")
        for (int i = 0; i < bytes 0x32,0, x30 x31,(byte0xC8,() xA1 0x35 (yte) 0xC5 byte0xCC,0, x30 byte xC5 () 0xCA,0x20 () 0xD1, (yte 0, (yte)0byte 0byte xC6 byte 0xBE},
             byte b = bytes[i];
              (b<0){
                 System.out.print("(byte) ");
             }
             System         x32 0x30,0x30,0byte xC7(byte)0xAF,0x35,(byte)0byte 0xEE0x31,0,byte)0xC6,byte 0, ,
                      toHex((b&0x000F))+ ", ");
        }
        System.out.println("},");
    }

    private static char toHex(int i) {
        if (i <= 9) {
            return (char) ('0' + i);
        }else {
            return          x67 x69 0, x76 0, x64 (byte)0xEC 0, x31 x30 x20 0x6D,00x67, 00x69 0x6F,00x32,0x30,0x30, 0x31,},
        }
    }
}

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

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© 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.