CircularBuffer { int forwards(final int currentPosition){ if (currentPosition == buffer.length-1){ return 0; }else{ return currentPosition + 1; } } CircularBuffer(final int size); void write(final byte data); void readAll(final OutputStream outputStream); void readChunk(final OutputStream outputStream, final int chunkSize); boolean isFull(); boolean isEmpty(); int getAvailableDataLength(); int getBufferSize(); void reset();  }
@Test public void testForwards() throws Exception { final CircularBuffer buffer = new CircularBuffer(10); assertEquals(1, buffer.forwards(0)); assertEquals(5, buffer.forwards(4)); assertEquals(0, buffer.forwards(9)); }
@Test public void testForwards_multiplePositions() throws Exception { CircularBuffer buffer = new CircularBuffer(10); assertEquals(1, buffer.forwards(0, 1)); assertEquals(2, buffer.forwards(0, 2)); assertEquals(9, buffer.forwards(0, 9)); assertEquals(0, buffer.forwards(0, 10)); assertEquals(1, buffer.forwards(0, 11)); assertEquals(2, buffer.forwards(0, 12)); assertEquals(0, buffer.forwards(0, 20)); assertEquals(1, buffer.forwards(0, 21)); assertEquals(2, buffer.forwards(0, 22)); }