[TEST] Fix AbstractBytesReferenceTestCase#testSlice to not assert on offset

This commit is contained in:
Simon Willnauer 2016-11-24 15:29:50 +01:00
parent ac2aa56350
commit 41e9ed13d6
1 changed files with 6 additions and 1 deletions

View File

@ -74,9 +74,14 @@ public abstract class AbstractBytesReferenceTestCase extends ESTestCase {
int sliceLength = Math.max(0, length - sliceOffset - 1);
BytesReference slice = pbr.slice(sliceOffset, sliceLength);
assertEquals(sliceLength, slice.length());
for (int i = 0; i < sliceLength; i++) {
assertEquals(pbr.get(i+sliceOffset), slice.get(i));
}
BytesRef singlePageOrNull = getSinglePageOrNull(slice);
if (singlePageOrNull != null) {
assertEquals(sliceOffset, singlePageOrNull.offset);
// we can't assert the offset since if the length is smaller than the refercence
// the offset can be anywhere
assertEquals(sliceLength, singlePageOrNull.length);
}
}