Package net.sf.cindy

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


            for (int j = 0; j < b.length; j++) {
                assertEquals(b[j], (byte) (start + j));
            }
        }
        for (int i = 0; i < 5; i++) {
            buffer.clear();
            byte[] b = new byte[random.nextInt(buffer.capacity())];
            int start = random.nextInt(buffer.capacity() - b.length);
            buffer.position(start);
            buffer.get(b);
            assertEquals(buffer.position(), start + b.length);
View Full Code Here


        Buffer buffer = newBuffer(256);
        for (int i = 0; i < 256; i++) {
            buffer.put((byte) i);
        }

        buffer.clear();
        ByteBuffer b1 = buffer.asByteBuffer();
        assertEquals(buffer.position(), b1.position());
        assertEquals(buffer.limit(), b1.limit());
        assertEquals(buffer.capacity(), b1.capacity());
        while (b1.hasRemaining())
View Full Code Here

        assertEquals(buffer.limit(), b1.limit());
        assertEquals(buffer.capacity(), b1.capacity());
        while (b1.hasRemaining())
            assertEquals(b1.get(), buffer.get());

        buffer.clear();
        buffer.limit(random.nextInt(buffer.capacity()));
        buffer.position(random.nextInt(buffer.limit()));
        ByteBuffer b2 = buffer.asByteBuffer();
        assertEquals(buffer.position(), b2.position());
        assertEquals(buffer.limit(), b2.limit());
View Full Code Here

        assertEquals(buffer.limit(), b2.limit());
        assertEquals(buffer.capacity(), b2.capacity());
        while (b2.hasRemaining())
            assertEquals(b2.get(), buffer.get());

        buffer.clear();
        buffer.limit(random.nextInt(buffer.capacity()));
        buffer.position(random.nextInt(buffer.limit()));
        buffer = buffer.slice();
        ByteBuffer b3 = buffer.asByteBuffer();
        assertEquals(buffer.position(), b3.position());
View Full Code Here

        byte b = (byte) random.nextInt(256);
        pattern[0] = b;
        pattern[1] = (byte) (b - 1);
        assertEquals(-1, buffer.indexOf(pattern));

        buffer.clear();
        int randomPosition = random.nextInt(buffer.capacity());
        buffer.position(randomPosition);
        buffer = buffer.slice();
        assertEquals(0, buffer.indexOf(new byte[] { (byte) randomPosition }));
    }
View Full Code Here

        buffer.putInt(0);
        buffer.compact();
        assertEquals(buffer.remaining(), 4);
        assertEquals(buffer.position(), 396);
        buffer.clear();

        for (int i = 0; i < 100; i++) {
            buffer.putInt(i);
        }
        buffer.flip();
View Full Code Here

        for (int i = 0; i < 100; i++) {
            assertEquals(i, buffer.getInt());
            buffer.compact();
            assertEquals(buffer.remaining(), 4);
            assertEquals(buffer.position(), 396);
            buffer.clear();
        }

        for (int i = 0; i < 256; i++) {
            buffer.put((byte) i);
        }
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.