jdk/test/java/nio/charset/coders/BashStreams.java
author katleman
Thu, 05 Jan 2012 08:42:37 -0800
changeset 11376 075fe3928b7f
parent 5991 288afdbbca28
child 30046 cf2c86e1819e
permissions -rw-r--r--
Added tag jdk8-b20 for changeset 90e14ec89395
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     4
 *
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     8
 *
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    13
 * accompanied this code).
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    14
 *
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    21
 * questions.
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    22
 */
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    23
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    24
/* @test
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    25
 * @summary Stochastic test of charset-based streams
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    26
 */
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    27
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    28
import java.io.*;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    29
import java.util.*;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    30
import java.nio.*;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    31
import java.nio.channels.*;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    32
import java.nio.charset.*;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    33
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    34
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    35
public class BashStreams {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    36
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    37
    static final PrintStream log = System.err;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    38
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    39
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    40
    static class CharacterGenerator {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    41
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    42
        private final Random rand;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    43
        private final int max;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    44
        private final int limit;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    45
        private int count = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    46
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    47
        CharacterGenerator(long seed, String csn, int limit) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    48
            rand = new Random(seed);
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
    49
            this.max = Character.MAX_CODE_POINT + 1;
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    50
            this.limit = limit;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    51
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    52
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    53
        private char[] saved = new char[10];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    54
        private int savedCount = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    55
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    56
        void push(char c) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    57
            saved[savedCount++] = c;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    58
            count--;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    59
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    60
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    61
        int count() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    62
            return count;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    63
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    64
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    65
        boolean hasNext() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    66
            return count < limit;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    67
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    68
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    69
        char next() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    70
            if (count >= limit)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    71
                throw new RuntimeException("EOF");
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    72
            if (savedCount > 0) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    73
                savedCount--;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    74
                count++;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    75
                return saved[savedCount];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    76
            }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    77
            int c;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    78
            for (;;) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    79
                c = rand.nextInt(max);
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
    80
                if ((Character.isBmpCodePoint(c)
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
    81
                     && (Character.isSurrogate((char) c)
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
    82
                         || (c == 0xfffe) || (c == 0xffff))))
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    83
                    continue;
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
    84
                if (Character.isSupplementaryCodePoint(c)
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
    85
                        && (count == limit - 1))
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    86
                    continue;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    87
                break;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    88
            }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    89
            count++;
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
    90
            if (Character.isSupplementaryCodePoint(c)) {
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    91
                count++;
5991
288afdbbca28 6933322: Add methods highSurrogate(), lowSurrogate() to class Character
martin
parents: 5986
diff changeset
    92
                push(Character.lowSurrogate(c));
288afdbbca28 6933322: Add methods highSurrogate(), lowSurrogate() to class Character
martin
parents: 5986
diff changeset
    93
                return Character.highSurrogate(c);
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    94
            }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    95
            return (char)c;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    96
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    97
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    98
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    99
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   100
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   101
    static void mismatch(String csn, int count, char c, char d) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   102
        throw new RuntimeException(csn + ": Mismatch at count "
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   103
                                   + count
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   104
                                   + ": " + Integer.toHexString(c)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   105
                                   + " != "
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   106
                                   + Integer.toHexString(d));
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   107
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   108
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   109
    static void mismatchedEOF(String csn, int count, int cgCount) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   110
        throw new RuntimeException(csn + ": Mismatched EOFs: "
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   111
                                   + count
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   112
                                   + " != "
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   113
                                   + cgCount);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   114
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   115
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   116
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   117
    static class Sink                   // One abomination...
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   118
        extends OutputStream
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   119
        implements WritableByteChannel
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   120
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   121
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   122
        private final String csn;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   123
        private final CharacterGenerator cg;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   124
        private int count = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   125
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   126
        Sink(String csn, long seed) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   127
            this.csn = csn;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   128
            this.cg = new CharacterGenerator(seed, csn, Integer.MAX_VALUE);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   129
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   130
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   131
        public void write(int b) throws IOException {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   132
            write (new byte[] { (byte)b }, 0, 1);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   133
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   134
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   135
        private int check(byte[] ba, int off, int len) throws IOException {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   136
            String s = new String(ba, off, len, csn);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   137
            int n = s.length();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   138
            for (int i = 0; i < n; i++) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   139
                char c = s.charAt(i);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   140
                char d = cg.next();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   141
                if (c != d) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   142
                    if (c == '?') {
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
   143
                        if (Character.isHighSurrogate(d))
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   144
                            cg.next();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   145
                        continue;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   146
                    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   147
                    mismatch(csn, count + i, c, d);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   148
                }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   149
            }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   150
            count += n;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   151
            return len;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   152
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   153
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   154
        public void write(byte[] ba, int off, int len) throws IOException {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   155
            check(ba, off, len);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   156
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   157
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   158
        public int write(ByteBuffer bb) throws IOException {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   159
            int n = check(bb.array(),
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   160
                          bb.arrayOffset() + bb.position(),
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   161
                          bb.remaining());
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   162
            bb.position(bb.position() + n);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   163
            return n;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   164
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   165
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   166
        public void close() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   167
            count = -1;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   168
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   169
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   170
        public boolean isOpen() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   171
            return count >= 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   172
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   173
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   174
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   175
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   176
    static void testWrite(String csn, int limit, long seed, Writer w)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   177
        throws IOException
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   178
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   179
        Random rand = new Random(seed);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   180
        CharacterGenerator cg = new CharacterGenerator(seed, csn,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   181
                                                       Integer.MAX_VALUE);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   182
        int count = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   183
        char[] ca = new char[16384];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   184
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   185
        int n = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   186
        while (count < limit) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   187
            n = rand.nextInt(ca.length);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   188
            for (int i = 0; i < n; i++)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   189
                ca[i] = cg.next();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   190
            w.write(ca, 0, n);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   191
            count += n;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   192
        }
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
   193
        if (Character.isHighSurrogate(ca[n - 1]))
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   194
            w.write(cg.next());
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   195
        w.close();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   196
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   197
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   198
    static void testStreamWrite(String csn, int limit, long seed)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   199
        throws IOException
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   200
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   201
        log.println("  write stream");
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   202
        testWrite(csn, limit, seed,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   203
                  new OutputStreamWriter(new Sink(csn, seed), csn));
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   204
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   205
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   206
    static void testChannelWrite(String csn, int limit, long seed)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   207
        throws IOException
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   208
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   209
        log.println("  write channel");
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   210
        testWrite(csn, limit, seed,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   211
                  Channels.newWriter(new Sink(csn, seed),
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   212
                                     Charset.forName(csn)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   213
                                     .newEncoder()
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   214
                                     .onMalformedInput(CodingErrorAction.REPLACE)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   215
                                     .onUnmappableCharacter(CodingErrorAction.REPLACE),
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   216
                                     8192));
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   217
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   218
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   219
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   220
    static class Source                 // ... and another
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   221
        extends InputStream
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   222
        implements ReadableByteChannel
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   223
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   224
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   225
        private final String csn;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   226
        private final CharsetEncoder enc;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   227
        private final CharacterGenerator cg;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   228
        private int count = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   229
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   230
        Source(String csn, long seed, int limit) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   231
            this.csn = csn.startsWith("\1") ? csn.substring(1) : csn;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   232
            this.enc = Charset.forName(this.csn).newEncoder()
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   233
                .onMalformedInput(CodingErrorAction.REPLACE)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   234
                .onUnmappableCharacter(CodingErrorAction.REPLACE);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   235
            this.cg = new CharacterGenerator(seed, csn, limit);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   236
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   237
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   238
        public int read() throws IOException {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   239
            byte[] b = new byte[1];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   240
            read(b);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   241
            return b[0];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   242
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   243
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   244
        private CharBuffer cb = CharBuffer.allocate(8192);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   245
        private ByteBuffer bb = null;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   246
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   247
        public int read(byte[] ba, int off, int len) throws IOException {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   248
            if (!cg.hasNext())
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   249
                return -1;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   250
            int end = off + len;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   251
            int i = off;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   252
            while (i < end) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   253
                if ((bb == null) || !bb.hasRemaining()) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   254
                    cb.clear();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   255
                    while (cb.hasRemaining()) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   256
                        if (!cg.hasNext())
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   257
                            break;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   258
                        char c = cg.next();
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
   259
                        if (Character.isHighSurrogate(c)
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
   260
                                && cb.remaining() == 1) {
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   261
                            cg.push(c);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   262
                            break;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   263
                        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   264
                        cb.put(c);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   265
                    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   266
                    cb.flip();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   267
                    if (!cb.hasRemaining())
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   268
                        break;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   269
                    bb = enc.encode(cb);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   270
                }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   271
                int d = Math.min(bb.remaining(), end - i);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   272
                bb.get(ba, i, d);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   273
                i += d;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   274
            }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   275
            return i - off;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   276
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   277
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   278
        public int read(ByteBuffer bb) throws IOException {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   279
            int n = read(bb.array(),
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   280
                         bb.arrayOffset() + bb.position(),
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   281
                         bb.remaining());
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   282
            if (n >= 0)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   283
                bb.position(bb.position() + n);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   284
            return n;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   285
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   286
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   287
        public void close() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   288
            count = -1;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   289
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   290
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   291
        public boolean isOpen() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   292
            return count != -1;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   293
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   294
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   295
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   296
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   297
    static void testRead(String csn, int limit, long seed, int max,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   298
                         Reader rd)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   299
        throws IOException
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   300
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   301
        Random rand = new Random(seed);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   302
        CharacterGenerator cg = new CharacterGenerator(seed, csn, limit);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   303
        int count = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   304
        char[] ca = new char[16384];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   305
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   306
        int n = 0;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   307
        while (count < limit) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   308
            int rn = rand.nextInt(ca.length);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   309
            n = rd.read(ca, 0, rn);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   310
            if (n < 0)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   311
                break;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   312
            for (int i = 0; i < n; i++) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   313
                char c = ca[i];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   314
                if (!cg.hasNext())
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   315
                    mismatchedEOF(csn, count + i, cg.count());
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   316
                char d = cg.next();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   317
                if (c == '?') {
5986
04eb44085c00 6934265: Add public method Character.isBmpCodePoint
martin
parents: 5506
diff changeset
   318
                    if (Character.isHighSurrogate(d)) {
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   319
                        cg.next();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   320
                        continue;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   321
                    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   322
                    if (d > max)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   323
                        continue;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   324
                }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   325
                if (c != d)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   326
                    mismatch(csn, count + i, c, d);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   327
            }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   328
            count += n;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   329
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   330
        if (cg.hasNext())
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   331
            mismatchedEOF(csn, count, cg.count());
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   332
        rd.close();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   333
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   334
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   335
    static void testStreamRead(String csn, int limit, long seed, int max)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   336
        throws IOException
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   337
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   338
        log.println("  read stream");
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   339
        testRead(csn, limit, seed, max,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   340
                 new InputStreamReader(new Source(csn, seed, limit), csn));
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   341
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   342
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   343
    static void testChannelRead(String csn, int limit, long seed, int max)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   344
        throws IOException
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   345
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   346
        log.println("  read channel");
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   347
        testRead(csn, limit, seed, max,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   348
                 Channels.newReader(new Source(csn, seed, limit), csn));
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   349
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   350
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   351
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   352
    static final int LIMIT = 1 << 21;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   353
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   354
    static void test(String csn, int limit, long seed, int max)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   355
        throws Exception
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   356
    {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   357
        log.println();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   358
        log.println(csn);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   359
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   360
        testStreamWrite(csn, limit, seed);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   361
        testChannelWrite(csn, limit, seed);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   362
        testStreamRead(csn, limit, seed, max);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   363
        testChannelRead(csn, limit, seed, max);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   364
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   365
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   366
    public static void main(String[] args) throws Exception {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   367
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   368
        if (System.getProperty("os.arch").equals("ia64")) {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   369
            // This test requires 54 minutes on an Itanium-1 processor
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   370
            return;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   371
        }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   372
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   373
        int ai = 0, an = args.length;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   374
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   375
        int limit;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   376
        if (ai < an)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   377
            limit = 1 << Integer.parseInt(args[ai++]);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   378
        else
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   379
            limit = LIMIT;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   380
        log.println("limit = " + limit);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   381
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   382
        long seed;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   383
        if (ai < an)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   384
            seed = Long.parseLong(args[ai++]);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   385
        else
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   386
            seed = System.currentTimeMillis();
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   387
        log.println("seed = " + seed);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   388
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   389
        test("UTF-8", limit, seed, Integer.MAX_VALUE);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   390
        test("US-ASCII", limit, seed, 0x7f);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   391
        test("ISO-8859-1", limit, seed, 0xff);
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   392
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   393
    }
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   394
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   395
}