test/jdk/sun/nio/cs/TestEBCDICLineFeed.java
author jiangli
Wed, 27 Sep 2017 17:55:20 -0400
changeset 47548 664b9d44db74
parent 47216 71c04702a3d5
permissions -rw-r--r--
8068314: "Java fields that are currently set during shared space dumping" comment is incorrect Summary: CDS dump time should also initialize preallocated out_of_memory error messages. Reviewed-by: iklam, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47025
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     1
/*
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     4
 *
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     8
 *
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    13
 * accompanied this code).
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    14
 *
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    18
 *
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    21
 * questions.
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    22
 */
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    23
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    24
/* @test
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    25
 * @bug 8186803
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    26
 * @summary Check if the linefeed is de/encoded correctly in ebcdic
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    27
 * @modules jdk.charsets
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    28
 */
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    29
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    30
public class TestEBCDICLineFeed {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    31
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    32
    public static void main(String[] args) throws Exception {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    33
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    34
        String[] csnames = new String[] {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    35
            "IBM037",  "IBM1025", "IBM1026", "IBM1112", "IBM1122", "IBM1123",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    36
            "IBM1166", "IBM273",  "IBM277",  "IBM278",  "IBM280",  "IBM284",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    37
            "IBM285",  "IBM297",  "IBM420",  "IBM424",  "IBM500",  "IBM838",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    38
            "IBM870",  "IBM871",   "IBM875", "IBM918",  "IBM930",  "IBM935",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    39
            "IBM937",  "IBM939",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    40
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    41
            "IBM01140", "IBM01141", "IBM01142", "IBM01143", "IBM01144",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    42
            "IBM01145", "IBM01146", "IBM01147", "IBM01148", "IBM01149",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    43
        };
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    44
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    45
        int errs = 0;
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    46
        for (String cs : csnames) {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    47
            byte[] bb = "\n".getBytes(cs);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    48
            if (bb.length != 1 || bb[0] != 0x15) {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    49
                System.out.printf(" error: %s c2b  u+000A -> %x%n",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    50
                                  cs,  bb[0] & 0xff);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    51
                errs++;
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    52
            }
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    53
            bb = "\u0085".getBytes(cs);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    54
            if (bb.length != 1 || bb[0] != 0x15) {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    55
                System.out.printf(" error: %s c2b  u+0085 -> %x%n",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    56
                                  cs,  bb[0] & 0xff);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    57
                errs++;
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    58
            }
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    59
            String str = new String(new byte[] { 0x15 }, cs);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    60
            if (!str.equals("\n")) {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    61
                System.out.printf(" error: %s b2c  0015 -> 0x%x%n",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    62
                                  cs, str.toCharArray()[0] & 0xffff);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    63
            }
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    64
            str = new String(new byte[] { 0x25 }, cs);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    65
            if (!str.equals("\n")) {
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    66
                System.out.printf(" error: %s b2c  0025 -> 0x%x%n",
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    67
                                  cs, str.toCharArray()[0] & 0xffff);
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    68
            }
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    69
        }
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    70
        if (errs > 0)
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    71
            throw new Exception(errs + " error(s) detected");
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    72
    }
e78bddc74bf5 8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
diff changeset
    73
}