1516171819202122232425
@Test public void testBig() { String str = "hello world!!! the quick brown fox jumps over the lazy dog"; buf = new CircularByteBuffer(10); a = str.getBytes(); b = new byte[500]; System.out.println("big a: " + Arrays.toString(a)); int written = buf.write(a, 0, a.length);
3839404142434445464748
public void testGrowWriteRead() { int i; String str = "123456789"; buf = new CircularByteBuffer(10); a = str.getBytes(); b = new byte[500]; assertTrue(a.length < b.length);
6263646566676869707172
@Test public void testSingleWriteRead() { buf = new CircularByteBuffer(5); for (int i = 0; i < 10; i++) { buf.write(100 + i); }
8182838485868788899091
} @Test public void testCapacityAvailable() { int cap = 10; buf = new CircularByteBuffer(cap); byte[] data = new byte[] { 1, 2, 3, 4 }; assertEquals(cap, buf.totalCapacity()); buf.write(data, 0, data.length); assertEquals(cap, buf.totalCapacity());
9596979899100101102103104105
@Test public void testWrap() { int cap = 10; buf = new CircularByteBuffer(cap); byte[] data = new byte[cap - 1]; for (int i = 0; i < data.length; i++) { data[i] = (byte) ((1 + i) & 0xff); }
120121122123124125126127128129130
} @Test public void testWrap2() { buf = new CircularByteBuffer(10); a = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; b = new byte[500]; int written, read; assertEquals(7, buf.write(a, 0, 7));