Fix test edge case for random bytes reference iter.

Getting an offset to the last byte means we can only stream one byte and
then we are done, we can't get another offset after it.
This commit is contained in:
Ryan Ernst 2016-07-10 09:11:32 -07:00
parent ab8b577aea
commit 25ed93dd28
1 changed files with 3 additions and 0 deletions

View File

@ -271,6 +271,9 @@ public abstract class AbstractBytesReferenceTestCase extends ESTestCase {
final int offset = randomIntBetween(0, length-1);
assertEquals(offset, input.skip(offset));
assertEquals(pbr.get(offset), input.readByte());
if (offset == length - 1) {
continue; // no more bytes to retrieve!
}
final int nextOffset = randomIntBetween(offset, length-2);
assertEquals(nextOffset - offset, input.skip(nextOffset - offset));
assertEquals(pbr.get(nextOffset+1), input.readByte()); // +1 for the one byte we read above