public static void main(String[] args) {
testLongChunkBuffer();
}
public static void testLongChunkBuffer(){
LArrayChunkedBuffer arrayChunkedBuffer = new LArrayChunkedBuffer();
if(arrayChunkedBuffer.hasNext()){
throw new RuntimeException();
}
int max = 2000;
for (int i = 0; i < max; i++) {
arrayChunkedBuffer.add(i);
}
for (int i = 0; i < max; i++) {
if(!arrayChunkedBuffer.hasNext()){
throw new RuntimeException();
}
if(arrayChunkedBuffer.next()!=i){
throw new RuntimeException();
}
}
arrayChunkedBuffer.setIteratorDirection(false);
for (int i = max-1; i >= 0 ; i--) {
if(!arrayChunkedBuffer.hasNext()){
throw new RuntimeException();
}
if(arrayChunkedBuffer.next()!=i){
throw new RuntimeException();
}
}
long[] bufferAsArray = arrayChunkedBuffer.toArray();
for (int i = 0; i < bufferAsArray.length; i++) {
if(bufferAsArray[i]!=max-i-1){
throw new RuntimeException();
}
}
arrayChunkedBuffer.setIteratorDirection(true);
bufferAsArray = arrayChunkedBuffer.toArray();
for (int i = 0; i < bufferAsArray.length; i++) {
if (bufferAsArray[i] != i) {
throw new RuntimeException();
}