jdk/test/java/nio/Buffer/BasicFloat.java
author alanb
Wed, 15 Apr 2009 14:53:34 +0100
changeset 2593 76032557be03
parent 1639 a97859015238
child 4502 18f387917b89
permissions -rw-r--r--
6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer Reviewed-by: sherman, iris
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1639
a97859015238 6785258: Update copyright year
xdono
parents: 1634
diff changeset
     2
 * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/* Type-specific source code for unit test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * We check in the generated source files so that the test tree can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * independently of the rest of the source tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
// -- This file was mechanically generated: Do not edit! -- //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.nio.*;
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
    34
import java.lang.reflect.Method;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class BasicFloat
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    extends Basic
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private static void relGet(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        float v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
            ck(b, (long)b.get(), (long)((float)ic(i)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private static void relGet(FloatBuffer b, int start) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        int n = b.remaining();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        float v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        for (int i = start; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            ck(b, (long)b.get(), (long)((float)ic(i)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static void absGet(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        float v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            ck(b, (long)b.get(), (long)((float)ic(i)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private static void bulkGet(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        float[] a = new float[n + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        b.get(a, 7, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            ck(b, (long)a[i + 7], (long)((float)ic(i)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static void relPut(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            b.put((float)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static void absPut(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            b.put(i, (float)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        b.limit(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private static void bulkPutArray(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        float[] a = new float[n + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            a[i + 7] = (float)ic(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        b.put(a, 7, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private static void bulkPutBuffer(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        FloatBuffer c = FloatBuffer.allocate(n + 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        c.position(7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            c.put((float)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        c.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        c.position(7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        b.put(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    //6231529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    private static void callReset(FloatBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        b.mark();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        b.duplicate().reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        b.asReadOnlyBuffer().reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    // 6221101-6234263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    private static void putBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        final int cap = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        FloatBuffer direct1 = ByteBuffer.allocateDirect(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        FloatBuffer nondirect1 = ByteBuffer.allocate(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        direct1.put(nondirect1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        FloatBuffer direct2 = ByteBuffer.allocateDirect(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        FloatBuffer nondirect2 = ByteBuffer.allocate(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        nondirect2.put(direct2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        FloatBuffer direct3 = ByteBuffer.allocateDirect(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        FloatBuffer direct4 = ByteBuffer.allocateDirect(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        direct3.put(direct4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        FloatBuffer nondirect3 = ByteBuffer.allocate(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        FloatBuffer nondirect4 = ByteBuffer.allocate(cap).asFloatBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        nondirect3.put(nondirect4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    private static void checkSlice(FloatBuffer b, FloatBuffer slice) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        ck(slice, 0, slice.position());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        ck(slice, b.remaining(), slice.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        ck(slice, b.remaining(), slice.capacity());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (b.isDirect() != slice.isDirect())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            fail("Lost direction", slice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (b.isReadOnly() != slice.isReadOnly())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            fail("Lost read-only", slice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   287
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   288
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   289
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   290
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   291
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   292
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   293
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   294
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   295
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   296
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   297
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   298
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   299
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   300
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   301
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   302
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   303
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   304
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   305
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   306
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   307
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   308
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   309
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   310
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   311
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    private static void tryCatch(Buffer b, Class ex, Runnable thunk) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        boolean caught = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            thunk.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        } catch (Throwable x) {
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   317
            if (ex.isAssignableFrom(x.getClass())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                caught = true;
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   319
            } else {
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   320
                fail(x.getMessage() + " not expected");
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   321
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        if (!caught)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            fail(ex.getName() + " not thrown", b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    private static void tryCatch(float [] t, Class ex, Runnable thunk) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        tryCatch(FloatBuffer.wrap(t), ex, thunk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public static void test(int level, final FloatBuffer b, boolean direct) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        show(level, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        if (direct != b.isDirect())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            fail("Wrong direction", b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        // Gets and puts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        absGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        bulkGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        absPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        absGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        bulkGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        bulkPutArray(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        bulkPutBuffer(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
2593
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   378
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   379
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   380
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        // Compact
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        b.position(13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        b.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        relGet(b, 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        // Exceptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        b.limit(b.capacity() / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        b.position(b.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        tryCatch(b, BufferUnderflowException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    b.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        tryCatch(b, BufferOverflowException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    b.put((float)42);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        // The index must be non-negative and lesss than the buffer's limit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        tryCatch(b, IndexOutOfBoundsException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                    b.get(b.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        tryCatch(b, IndexOutOfBoundsException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                    b.get(-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        tryCatch(b, IndexOutOfBoundsException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                    b.put(b.limit(), (float)42);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   420
        tryCatch(b, InvalidMarkException.class, new Runnable() {
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   421
                public void run() {
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   422
                    b.position(0);
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   423
                    b.mark();
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   424
                    b.compact();
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   425
                    b.reset();
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   426
                }});
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   427
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        // Values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        b.put((float)0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        b.put((float)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        b.put((float)1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        b.put(Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        b.put(Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        b.put(-Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        b.put(-Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        b.put(Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        b.put(Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        b.put(Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        b.put(0.91697687f);             // Changes value if incorrectly swapped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        float v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        ck(b, b.get(), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        ck(b, b.get(), (float)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        ck(b, b.get(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        ck(b, b.get(), Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        ck(b, b.get(), Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        ck(b, b.get(), -Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        ck(b, b.get(), -Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        ck(b, b.get(), Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        ck(b, b.get(), Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        if (Float.floatToRawIntBits(v = b.get()) != Float.floatToRawIntBits(Float.NaN))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            fail(b, (long)Float.NaN, (long)v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        ck(b, b.get(), 0.91697687f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        // Comparison
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        FloatBuffer b2 = FloatBuffer.allocate(b.capacity());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        b2.put(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        b2.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        b.position(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        b2.position(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        if (!b.equals(b2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            for (int i = 2; i < b.limit(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                float x = b.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                float y = b2.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                if (x != y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                    || Float.compare(x, y) != 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                    )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                    out.println("[" + i + "] " + x + " != " + y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            fail("Identical buffers not equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        if (b.compareTo(b2) != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            fail("Comparison to identical buffer != 0", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        b.limit(b.limit() + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        b.position(b.limit() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        b.put((float)99);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        b2.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        if (b.equals(b2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            fail("Non-identical buffers equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        if (b.compareTo(b2) <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            fail("Comparison to shorter buffer <= 0", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        b.limit(b.limit() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        b.put(2, (float)42);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        if (b.equals(b2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            fail("Non-identical buffers equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        if (b.compareTo(b2) <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            fail("Comparison to lesser buffer <= 0", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        // Sub, dup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        relGet(b.duplicate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        b.position(13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        relGet(b.duplicate(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        relGet(b.duplicate().slice(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        relGet(b.slice(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        relGet(b.slice().duplicate(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        // Slice
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        b.position(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        FloatBuffer sb = b.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        checkSlice(b, sb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        FloatBuffer sb2 = sb.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        checkSlice(sb, sb2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        if (!sb.equals(sb2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            fail("Sliced slices do not match", sb, sb2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        if ((sb.hasArray()) && (sb.arrayOffset() != sb2.arrayOffset()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            fail("Array offsets do not match: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                 + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        // Read-only views
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        final FloatBuffer rb = b.asReadOnlyBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        if (!b.equals(rb))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            fail("Buffer not equal to read-only view", b, rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        show(level + 1, rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                    relPut(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                    absPut(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                    bulkPutArray(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                    bulkPutBuffer(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                    rb.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        if (rb.getClass().getName().startsWith("java.nio.Heap")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                        rb.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                    }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                        rb.arrayOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                    }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            if (rb.hasArray())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                fail("Read-only heap buffer's backing array is accessible",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                     rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        // Bulk puts from read-only buffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        rb.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        b.put(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        relPut(b);                       // Required by testViews
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
2593
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   792
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   793
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    public static void test(final float [] ba) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        int offset = 47;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        int length = 900;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        final FloatBuffer b = FloatBuffer.wrap(ba, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        show(0, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        ck(b, b.capacity(), ba.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        ck(b, b.position(), offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        ck(b, b.limit(), offset + length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        // The offset must be non-negative and no larger than <array.length>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        tryCatch(ba, IndexOutOfBoundsException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                    FloatBuffer.wrap(ba, -1, ba.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        tryCatch(ba, IndexOutOfBoundsException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                    FloatBuffer.wrap(ba, ba.length + 1, ba.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        tryCatch(ba, IndexOutOfBoundsException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                    FloatBuffer.wrap(ba, 0, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        tryCatch(ba, IndexOutOfBoundsException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                    FloatBuffer.wrap(ba, 0, ba.length + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        // A NullPointerException will be thrown if the array is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        tryCatch(ba, NullPointerException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                    FloatBuffer.wrap((float []) null, 0, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        tryCatch(ba, NullPointerException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                    FloatBuffer.wrap((float []) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    private static void testAllocate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        // An IllegalArgumentException will be thrown for negative capacities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        tryCatch((Buffer) null, IllegalArgumentException.class, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                    FloatBuffer.allocate(-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    public static void test() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        testAllocate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        test(0, FloatBuffer.allocate(7 * 1024), false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        test(0, FloatBuffer.wrap(new float[7 * 1024], 0, 7 * 1024), false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        test(new float[1024]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        callReset(FloatBuffer.allocate(10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        putBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
}