1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.apache.harmony.nio.tests.java.nio;
19 import dalvik.annotation.TestLevel;
20 import dalvik.annotation.TestTargetNew;
21 import dalvik.annotation.TestTargetClass;
23 import java.nio.CharBuffer;
25 @TestTargetClass(java.nio.CharBuffer.class)
26 public class WrappedCharBufferTest1 extends CharBufferTest {
28 protected void setUp() throws Exception {
29 capacity = BUFFER_LENGTH;
30 buf = CharBuffer.wrap(new char[BUFFER_LENGTH]);
35 protected void tearDown() throws Exception {
41 * @tests java.nio.CharBuffer#allocate(char[],int,int)
45 level = TestLevel.PARTIAL_COMPLETE,
46 notes = "Verifies IndexOutOfBoundsException, NullPointerException.",
48 args = {java.lang.CharSequence.class, int.class, int.class}
50 public void testWrappedCharBuffer_IllegalArg() {
51 char array[] = new char[BUFFER_LENGTH];
53 CharBuffer.wrap(array, -1, 0);
54 fail("Should throw Exception");
55 } catch (IndexOutOfBoundsException e) {
59 CharBuffer.wrap(array, BUFFER_LENGTH + 1, 0);
60 fail("Should throw Exception");
61 } catch (IndexOutOfBoundsException e) {
65 CharBuffer.wrap(array, 0, -1);
66 fail("Should throw Exception");
67 } catch (IndexOutOfBoundsException e) {
71 CharBuffer.wrap(array, 0, BUFFER_LENGTH + 1);
72 fail("Should throw Exception");
73 } catch (IndexOutOfBoundsException e) {
77 CharBuffer.wrap(array, Integer.MAX_VALUE, 1);
78 fail("Should throw Exception");
79 } catch (IndexOutOfBoundsException e) {
83 CharBuffer.wrap(array, 1, Integer.MAX_VALUE);
84 fail("Should throw Exception");
85 } catch (IndexOutOfBoundsException e) {
89 CharBuffer.wrap((char[])null, -1, 0);
90 fail("Should throw NPE");
91 } catch (NullPointerException e) {