Package net.sf.cindy

Examples of net.sf.cindy.Buffer.limit()


            buffer.put((byte) i);
        }
        while (buffer.hasRemaining())
            buffer.put((byte) 0);
        buffer.position(100);
        buffer.limit(200);

        Buffer b = buffer.slice();
        b.position(40);
        b.compact();
        assertEquals(b.position(), 60);
View Full Code Here


        Buffer b = buffer.slice();
        b.position(40);
        b.compact();
        assertEquals(b.position(), 60);
        assertEquals(b.limit(), 100);

        for (int i = 0; i < 60; i++) {
            assertEquals(b.get(i), (byte) (140 + i));
        }
    }
View Full Code Here

            Buffer buffer = newBuffer(b.length);
            buffer.put(b);
            assertEquals(b.length, buffer.position());
            buffer.flip();
            assertEquals(0, buffer.position());
            assertEquals(b.length, buffer.limit());
            assertEquals(b.length, buffer.capacity());
            assertEquals(b.length, buffer.remaining());
            assertTrue(buffer.hasRemaining());
            assertEquals(buffer.asByteBuffer(), ByteBuffer.wrap(b));
View Full Code Here

            assertEquals(buffer.asByteBuffer(), ByteBuffer.wrap(b));

            random.nextBytes(b);
            buffer.put(ByteBuffer.wrap(b));
            assertEquals(b.length, buffer.position());
            assertEquals(b.length, buffer.limit());
            assertEquals(b.length, buffer.capacity());
            assertEquals(0, buffer.remaining());
            assertFalse(buffer.hasRemaining());
            buffer.flip();
            assertEquals(buffer.asByteBuffer(), ByteBuffer.wrap(b));
View Full Code Here

            assertEquals(0, buffer.remaining());
            assertFalse(buffer.hasRemaining());
            buffer.flip();
            assertEquals(buffer.asByteBuffer(), ByteBuffer.wrap(b));
            assertEquals(0, buffer.position());
            assertEquals(b.length, buffer.limit());
            assertEquals(b.length, buffer.remaining());
            assertEquals(b.length, buffer.capacity());
            assertTrue(buffer.hasRemaining());

            Buffer b1 = newBuffer(b.length);
View Full Code Here

        random.nextBytes(b);
        ByteBuffer b1 = ByteBuffer.wrap(b);

        Buffer buffer = ByteBufferBuffer.wrap(b1);
        assertEquals(0, buffer.position());
        assertEquals(b1.limit(), buffer.limit());
        assertEquals(b1.capacity(), buffer.capacity());
        assertEquals(b1.remaining(), buffer.remaining());
        for (int i = 0; i < b.length; i++) {
            assertEquals(b[i], buffer.get());
        }
View Full Code Here

        int offset = random.nextInt(b.length);
        int len = b.length - offset;
        b1 = ByteBuffer.wrap(b, offset, len);
        buffer = ByteBufferBuffer.wrap(b1);
        assertEquals(b1.position(), buffer.position());
        assertEquals(b1.limit(), buffer.limit());
        assertEquals(b1.capacity(), buffer.capacity());
        assertEquals(b1.remaining(), buffer.remaining());
        while (b1.hasRemaining()) {
            assertEquals(b1.get(), buffer.get());
        }
View Full Code Here

    public void testWrap() {
        byte[] b = new byte[random.nextInt(10000)];
        random.nextBytes(b);
        Buffer buffer = ByteArrayBuffer.wrap(b);
        assertEquals(0, buffer.position());
        assertEquals(b.length, buffer.limit());
        assertEquals(b.length, buffer.capacity());
        assertEquals(b.length, buffer.remaining());
        for (int i = 0; i < b.length; i++) {
            assertEquals(b[i], buffer.get());
        }
View Full Code Here

        int offset = random.nextInt(b.length);
        int len = b.length - offset;
        buffer = ByteArrayBuffer.wrap(b, offset, len);
        assertEquals(offset, buffer.position());
        assertEquals(b.length, buffer.limit());
        assertEquals(b.length, buffer.capacity());
        assertEquals(len, buffer.remaining());
        for (int i = offset; i < b.length; i++) {
            assertEquals(b[i], buffer.get());
        }
View Full Code Here

    public void testCreate() {
        for (int i = 0; i < 5; i++) {
            int capacity = random.nextInt(1000) + 1;
            Buffer buffer = newBuffer(capacity);
            assertEquals(0, buffer.position());
            assertEquals(capacity, buffer.limit());
            assertEquals(capacity, buffer.capacity());
            assertEquals(capacity, buffer.remaining());
            assertTrue(buffer.hasRemaining());
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.