jdk/test/sun/nio/cs/ISCIITest.java
author never
Mon, 12 Jul 2010 22:27:18 -0700
changeset 5926 a36f90d986b6
parent 5506 202f599c92aa
child 44115 bb4e971bf5d4
permissions -rw-r--r--
6968385: malformed xml in sweeper logging Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
796
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 796
diff changeset
     2
 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
796
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     4
 *
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     8
 *
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    13
 * accompanied this code).
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    14
 *
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 796
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 796
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 796
diff changeset
    21
 * questions.
796
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    22
 */
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    23
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    24
/* @test
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    25
   @bug 4328178
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    26
   @summary Performs baseline and regression test on the ISCII91 charset
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    27
 */
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    28
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    29
import java.io.*;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    30
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    31
public class ISCIITest {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    32
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    33
    private static void failureReport() {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    34
        System.err.println ("Failed ISCII91 Regression Test");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    35
    }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    36
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    37
    private static void mapEquiv(int start,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    38
                                 int end,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    39
                                 String testName)
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    40
    throws Exception
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    41
    {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    42
        byte[] singleByte = new byte[1];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    43
        byte[] encoded = new byte[1];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    44
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    45
        for (int i = start; i <= end; i++ ) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    46
            singleByte[0] = (byte) i;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    47
            try {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    48
                String unicodeStr =
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    49
                        new String (singleByte,"ISCII91");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    50
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    51
                if (i != (int)unicodeStr.charAt(0)) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    52
                    System.err.println ("FAILED ISCII91 Regression test"
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    53
                                        + "input byte is " + i );
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    54
                    throw new Exception("");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    55
                }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    56
                encoded = unicodeStr.getBytes("ISCII91");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    57
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    58
                if (encoded[0] != singleByte[0]) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    59
                   System.err.println("Encoding error " + testName);
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    60
                   throw new Exception("Failed ISCII91 Regression test");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    61
                }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    62
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    63
            } catch (UnsupportedEncodingException e) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    64
                failureReport();
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    65
            }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    66
        }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    67
        return;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    68
    }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    69
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    70
    private static void checkUnmapped(int start,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    71
                                      int end,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    72
                                      String testName)
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    73
    throws Exception {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    74
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    75
        byte[] singleByte = new byte[1];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    76
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    77
        for (int i = start; i <= end; i++ ) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    78
            singleByte[0] = (byte) i;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    79
            try {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    80
                String unicodeStr = new String (singleByte, "ISCII91");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    81
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    82
                if (unicodeStr.charAt(0) != '\uFFFD') {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    83
                    System.err.println("FAILED " + testName +
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    84
                                        "input byte is " + i );
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    85
                    throw new Exception ("Failed ISCII91 regression test");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    86
                }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    87
            } catch (UnsupportedEncodingException e) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    88
                System.err.println("Unsupported character encoding");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    89
            }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    90
        }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    91
        return;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    92
    }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    93
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    94
    /*
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    95
     *
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    96
     */
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    97
    private static void checkRange(int start, int end,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    98
                                   char[] expectChars,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
    99
                                   String testName)
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   100
                                   throws Exception {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   101
        byte[] singleByte = new byte[1];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   102
        byte[] encoded = new byte[1];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   103
        int lookupOffset = 0;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   104
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   105
        for (int i=start; i <= end; i++ ) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   106
            singleByte[0] = (byte) i;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   107
            String unicodeStr = new String (singleByte, "ISCII91");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   108
            if (unicodeStr.charAt(0) != expectChars[lookupOffset++]) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   109
                throw new Exception ("Failed ISCII91 Regression Test");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   110
            }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   111
            encoded = unicodeStr.getBytes("ISCII");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   112
        }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   113
        return;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   114
    }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   115
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   116
    /*
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   117
     * Tests the ISCII91 Indic character encoding
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   118
     * as per IS 13194:1991 Bureau of Indian Standards.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   119
     */
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   120
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   121
    private static void test () throws Exception {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   122
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   123
        try {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   124
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   125
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   126
            // ISCII91 is an 8-byte encoding which retains the ASCII
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   127
            // mappings in the lower half.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   128
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   129
            mapEquiv(0, 0x7f, "7 bit ASCII range");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   130
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   131
            // Checks a range of characters which are unmappable according
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   132
            // to the standards.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   133
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   134
            checkUnmapped(0x81, 0x9f, "UNMAPPED");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   135
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   136
            // Vowel Modifier chars can be used to modify the vowel
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   137
            // sound of the preceding consonant, vowel or matra character.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   138
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   139
            byte[] testByte = new byte[1];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   140
            char[] vowelModChars = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   141
                '\u0901', // Vowel modifier Chandrabindu
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   142
                '\u0902', // Vowel modifier Anuswar
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   143
                '\u0903'  // Vowel modifier Visarg
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   144
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   145
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   146
            checkRange(0xa1, 0xa3, vowelModChars, "INDIC VOWEL MODIFIER CHARS");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   147
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   148
            char[] expectChars = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   149
                '\u0905', // a4 -- Vowel A
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   150
                '\u0906', // a5 -- Vowel AA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   151
                '\u0907', // a6 -- Vowel I
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   152
                '\u0908', // a7 -- Vowel II
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   153
                '\u0909', // a8 -- Vowel U
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   154
                '\u090a', // a9 -- Vowel UU
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   155
                '\u090b', // aa -- Vowel RI
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   156
                '\u090e', // ab -- Vowel E ( Southern Scripts )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   157
                '\u090f', // ac -- Vowel EY
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   158
                '\u0910', // ad -- Vowel AI
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   159
                '\u090d', // ae -- Vowel AYE ( Devanagari Script )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   160
                '\u0912', // af -- Vowel O ( Southern Scripts )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   161
                '\u0913', // b0 -- Vowel OW
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   162
                '\u0914', // b1 -- Vowel AU
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   163
                '\u0911', // b2 -- Vowel AWE ( Devanagari Script )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   164
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   165
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   166
            checkRange(0xa4, 0xb2, expectChars, "INDIC VOWELS");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   167
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   168
            char[] expectConsChars =
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   169
            {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   170
                '\u0915', // b3 -- Consonant KA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   171
                '\u0916', // b4 -- Consonant KHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   172
                '\u0917', // b5 -- Consonant GA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   173
                '\u0918', // b6 -- Consonant GHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   174
                '\u0919', // b7 -- Consonant NGA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   175
                '\u091a', // b8 -- Consonant CHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   176
                '\u091b', // b9 -- Consonant CHHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   177
                '\u091c', // ba -- Consonant JA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   178
                '\u091d', // bb -- Consonant JHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   179
                '\u091e', // bc -- Consonant JNA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   180
                '\u091f', // bd -- Consonant Hard TA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   181
                '\u0920', // be -- Consonant Hard THA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   182
                '\u0921', // bf -- Consonant Hard DA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   183
                '\u0922', // c0 -- Consonant Hard DHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   184
                '\u0923', // c1 -- Consonant Hard NA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   185
                '\u0924', // c2 -- Consonant Soft TA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   186
                '\u0925', // c3 -- Consonant Soft THA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   187
                '\u0926', // c4 -- Consonant Soft DA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   188
                '\u0927', // c5 -- Consonant Soft DHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   189
                '\u0928', // c6 -- Consonant Soft NA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   190
                '\u0929', // c7 -- Consonant NA ( Tamil )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   191
                '\u092a', // c8 -- Consonant PA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   192
                '\u092b', // c9 -- Consonant PHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   193
                '\u092c', // ca -- Consonant BA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   194
                '\u092d', // cb -- Consonant BHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   195
                '\u092e', // cc -- Consonant MA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   196
                '\u092f', // cd -- Consonant YA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   197
                '\u095f', // ce -- Consonant JYA ( Bengali, Assamese & Oriya )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   198
                '\u0930', // cf -- Consonant RA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   199
                '\u0931', // d0 -- Consonant Hard RA ( Southern Scripts )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   200
                '\u0932', // d1 -- Consonant LA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   201
                '\u0933', // d2 -- Consonant Hard LA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   202
                '\u0934', // d3 -- Consonant ZHA ( Tamil & Malayalam )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   203
                '\u0935', // d4 -- Consonant VA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   204
                '\u0936', // d5 -- Consonant SHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   205
                '\u0937', // d6 -- Consonant Hard SHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   206
                '\u0938', // d7 -- Consonant SA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   207
                '\u0939', // d8 -- Consonant HA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   208
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   209
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   210
            checkRange(0xb3, 0xd8, expectConsChars, "INDIC CONSONANTS");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   211
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   212
            char[] matraChars = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   213
                '\u093e', // da -- Vowel Sign AA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   214
                '\u093f', // db -- Vowel Sign I
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   215
                '\u0940', // dc -- Vowel Sign II
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   216
                '\u0941', // dd -- Vowel Sign U
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   217
                '\u0942', // de -- Vowel Sign UU
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   218
                '\u0943', // df -- Vowel Sign RI
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   219
                '\u0946', // e0 -- Vowel Sign E ( Southern Scripts )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   220
                '\u0947', // e1 -- Vowel Sign EY
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   221
                '\u0948', // e2 -- Vowel Sign AI
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   222
                '\u0945', // e3 -- Vowel Sign AYE ( Devanagari Script )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   223
                '\u094a', // e4 -- Vowel Sign O ( Southern Scripts )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   224
                '\u094b', // e5 -- Vowel Sign OW
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   225
                '\u094c', // e6 -- Vowel Sign AU
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   226
                '\u0949' // e7 -- Vowel Sign AWE ( Devanagari Script )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   227
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   228
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   229
            // Matras or Vowel signs alter the implicit
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   230
            // vowel sound associated with an Indic consonant.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   231
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   232
            checkRange(0xda, 0xe7, matraChars, "INDIC MATRAS");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   233
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   234
            char[] loneContextModifierChars = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   235
            '\u094d', // e8 -- Vowel Omission Sign ( Halant )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   236
            '\u093c', // e9 -- Diacritic Sign ( Nukta )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   237
            '\u0964' // ea -- Full Stop ( Viram, Northern Scripts )
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   238
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   239
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   240
            checkRange(0xe8, 0xea,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   241
                       loneContextModifierChars, "LONE INDIC CONTEXT CHARS");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   242
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   243
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   244
            // Test Indic script numeral chars
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   245
            // (as opposed to international numerals)
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   246
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   247
            char[] expectNumeralChars =
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   248
            {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   249
                '\u0966', // f1 -- Digit 0
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   250
                '\u0967', // f2 -- Digit 1
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   251
                '\u0968', // f3 -- Digit 2
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   252
                '\u0969', // f4 -- Digit 3
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   253
                '\u096a', // f5 -- Digit 4
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   254
                '\u096b', // f6 -- Digit 5
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   255
                '\u096c', // f7 -- Digit 6
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   256
                '\u096d', // f8 -- Digit 7
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   257
                '\u096e', // f9 -- Digit 8
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   258
                '\u096f'  // fa -- Digit 9
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   259
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   260
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   261
            checkRange(0xf1, 0xfa,
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   262
                       expectNumeralChars, "NUMERAL/DIGIT CHARACTERS");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   263
            int lookupOffset = 0;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   264
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   265
            char[] expectNuktaSub = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   266
                '\u0950',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   267
                '\u090c',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   268
                '\u0961',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   269
                '\u0960',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   270
                '\u0962',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   271
                '\u0963',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   272
                '\u0944',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   273
                '\u093d'
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   274
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   275
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   276
            /*
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   277
             * ISCII uses a number of code extension techniques
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   278
             * to access a number of lesser used characters.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   279
             * The Nukta character which ordinarily signifies
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   280
             * a diacritic is used in combination with existing
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   281
             * characters to escape them to a different character.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   282
             * value.
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   283
            */
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   284
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   285
            byte[] codeExtensionBytes = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   286
                (byte)0xa1 , (byte)0xe9, // Chandrabindu + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   287
                                         // =>DEVANAGARI OM SIGN
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   288
                (byte)0xa6 , (byte)0xe9, // Vowel I + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   289
                                         // => DEVANAGARI VOCALIC L
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   290
                (byte)0xa7 , (byte)0xe9, // Vowel II + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   291
                                         // => DEVANAGARI VOCALIC LL
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   292
                (byte)0xaa , (byte)0xe9, // Vowel RI + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   293
                                         // => DEVANAGARI VOCALIC RR
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   294
                (byte)0xdb , (byte)0xe9, //  Vowel sign I + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   295
                                         // => DEVANAGARI VOWEL SIGN VOCALIC L
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   296
                (byte)0xdc , (byte)0xe9, // Vowel sign II + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   297
                                         // => DEVANAGARI VOWEL SIGN VOCALIC LL
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   298
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   299
                (byte)0xdf , (byte)0xe9, // Vowel sign Vocalic R + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   300
                                         // => DEVANAGARI VOWEL SIGN VOCALIC RR
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   301
                (byte)0xea , (byte)0xe9  // Full stop/Phrase separator + Nukta
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   302
                                         // => DEVANAGARI SIGN AVAGRAHA
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   303
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   304
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   305
            lookupOffset = 0;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   306
            byte[] bytePair = new byte[2];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   307
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   308
            for (int i=0; i < (codeExtensionBytes.length)/2; i++ ) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   309
                bytePair[0] = (byte) codeExtensionBytes[lookupOffset++];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   310
                bytePair[1] = (byte) codeExtensionBytes[lookupOffset++];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   311
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   312
                String unicodeStr = new String (bytePair,"ISCII91");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   313
                if (unicodeStr.charAt(0) != expectNuktaSub[i]) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   314
                    throw new Exception("Failed Nukta Sub");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   315
                }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   316
            }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   317
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   318
            lookupOffset = 0;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   319
            byte[] comboBytes = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   320
                (byte)0xe8 , (byte)0xe8, //HALANT + HALANT
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   321
                (byte)0xe8 , (byte)0xe9  //HALANT + NUKTA    aka. Soft Halant
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   322
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   323
            char[] expectCombChars = {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   324
                '\u094d',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   325
                '\u200c',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   326
                '\u094d',
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   327
                '\u200d'
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   328
            };
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   329
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   330
            for (int i=0; i < (comboBytes.length)/2; i++ ) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   331
                bytePair[0] = (byte) comboBytes[lookupOffset++];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   332
                bytePair[1] = (byte) comboBytes[lookupOffset];
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   333
                String unicodeStr = new String (bytePair, "ISCII91");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   334
                if (unicodeStr.charAt(0) != expectCombChars[lookupOffset-1]
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   335
                    && unicodeStr.charAt(1) != expectCombChars[lookupOffset]) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   336
                    throw new Exception("Failed ISCII91 Regression Test");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   337
                }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   338
                lookupOffset++;
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   339
            }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   340
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   341
        } catch (UnsupportedEncodingException e) {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   342
             System.err.println ("ISCII91 encoding not supported");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   343
             throw new Exception ("Failed ISCII91 Regression Test");
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   344
        }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   345
    }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   346
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   347
    public static void main (String[] args) throws Exception {
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   348
        test();
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   349
    }
2c3db720c065 6675856: Open charset tests
sherman
parents:
diff changeset
   350
}