impl.write(wb, i);
num++;
}
//for (int i=0;i<b.remaining();i++) System.out.print(b.get(i)+"|");
w.stop();
ReadBuffer rb = wb.getStaticBuffer().asReadBuffer();
log.info("Writing " + num + " longs in " + rb.length() + " bytes. in time: " + w.getTime());
final ReadVerify read = new ReadVerify() {
@Override
public void next(ReadBuffer rb, long expected) {
int beforePos = rb.getPosition();
long value = impl.read(rb);
assertEquals(expected, value);
int length = Math.abs(rb.getPosition()-beforePos);
assertEquals("On: " + expected,length,impl.length(expected));
}
};
if (backward) {
rb.movePosition(rb.length()-1);
for (long i = maxValue; i != (negative?-maxValue:0); i -= jump) {
read.next(rb,i);
}
} else {
for (long i = (negative?-maxValue:0); i <= maxValue; i += jump) {
read.next(rb, i);
}
}
//Test boundaries
wb = new WriteByteBuffer(512);
impl.write(wb,0);
impl.write(wb,Long.MAX_VALUE);
if (negative) impl.write(wb,-Long.MAX_VALUE);
rb = wb.getStaticBuffer().asReadBuffer();
if (backward) {
rb.movePosition(rb.length()-1);
if (negative) assertEquals(-Long.MAX_VALUE, impl.read(rb));
assertEquals(Long.MAX_VALUE, impl.read(rb));
assertEquals(0, impl.read(rb));
} else {
assertEquals(0, impl.read(rb));