Provide a basic test for getBufferFor()

This commit is contained in:
Cruz Julian Bishop 2012-06-29 13:31:02 +10:00 committed by Trustin Lee
parent a280928731
commit 052f8be504

View File

@ -16,6 +16,7 @@
package io.netty.buffer;
import static io.netty.buffer.Unpooled.*;
import java.io.IOException;
import static org.junit.Assert.*;
import java.nio.ByteBuffer;
@ -90,6 +91,25 @@ public abstract class AbstractCompositeChannelBufferTest extends
return false;
}
/**
* Tests the "getBufferFor" method
*/
@Test
public void testGetBufferFor() throws IOException {
CompositeByteBuf buf = (CompositeByteBuf) Unpooled.wrappedBuffer(new byte[] { 1, 2, 3, 4, 5 }, new byte[] {4, 5, 6, 7, 8, 9, 26});
//Ensure that a random place will be fine
assertEquals(buf.getBufferFor(2).capacity(), 5);
//Loop through each byte
byte index = 0;
while (index < buf.capacity()) {
assertNotNull(buf.getBufferFor(index++));
}
}
@Test
public void testDiscardReadBytes3() {
ByteBuf a, b;