FileDocCategorySizeDatePackage
WrappedShortBufferTest.javaAPI DocAndroid 1.5 API3323Wed May 06 22:41:04 BST 2009org.apache.harmony.nio.tests.java.nio

WrappedShortBufferTest

public class WrappedShortBufferTest extends ShortBufferTest

Fields Summary
Constructors Summary
Methods Summary
protected voidsetUp()

        capacity = BUFFER_LENGTH;
        buf = ShortBuffer.wrap(new short[BUFFER_LENGTH]);
        loadTestData1(buf);
        baseBuf = buf;
    
protected voidtearDown()

        baseBuf = null;
        buf = null;
    
public voidtestWrappedShortBuffer_IllegalArg()

tests
java.nio.CharBuffer#allocate(char[],int,int)

        short array[] = new short[20];
        try {
            ShortBuffer.wrap(array, -1, 0);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ShortBuffer.wrap(array, 21, 0);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ShortBuffer.wrap(array, 0, -1);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ShortBuffer.wrap(array, 0, 21);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ShortBuffer.wrap(array, Integer.MAX_VALUE, 1);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ShortBuffer.wrap(array, 1, Integer.MAX_VALUE);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ShortBuffer.wrap((short[])null, -1, 0);
            fail("Should throw NPE"); //$NON-NLS-1$
        } catch (NullPointerException e) {
        }

        ShortBuffer buf = ShortBuffer.wrap(array, 2, 16);
        assertEquals(buf.position(), 2);
        assertEquals(buf.limit(), 18);
        assertEquals(buf.capacity(), 20);