mirror of https://github.com/apache/lucene.git
LUCENE-3563: fix test bug
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1198341 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8d7c081c8
commit
ed28039c43
|
@ -441,6 +441,7 @@ public final class PagedBytes {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readBytes(byte[] b, int offset, int len) {
|
public void readBytes(byte[] b, int offset, int len) {
|
||||||
|
assert b.length >= offset + len;
|
||||||
final int offsetEnd = offset + len;
|
final int offsetEnd = offset + len;
|
||||||
while (true) {
|
while (true) {
|
||||||
final int blockLeft = blockSize - currentBlockUpto;
|
final int blockLeft = blockSize - currentBlockUpto;
|
||||||
|
@ -485,6 +486,7 @@ public final class PagedBytes {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBytes(byte[] b, int offset, int length) throws IOException {
|
public void writeBytes(byte[] b, int offset, int length) throws IOException {
|
||||||
|
assert b.length >= offset + length;
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class TestPagedBytes extends LuceneTestCase {
|
||||||
if (random.nextInt(10) == 7) {
|
if (random.nextInt(10) == 7) {
|
||||||
out.writeByte(answer[written++]);
|
out.writeByte(answer[written++]);
|
||||||
} else {
|
} else {
|
||||||
int chunk = Math.max(random.nextInt(1000), numBytes - written);
|
int chunk = Math.min(random.nextInt(1000), numBytes - written);
|
||||||
out.writeBytes(answer, written, chunk);
|
out.writeBytes(answer, written, chunk);
|
||||||
written += chunk;
|
written += chunk;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class TestPagedBytes extends LuceneTestCase {
|
||||||
if (random.nextInt(10) == 7) {
|
if (random.nextInt(10) == 7) {
|
||||||
verify[read++] = in.readByte();
|
verify[read++] = in.readByte();
|
||||||
} else {
|
} else {
|
||||||
int chunk = Math.max(random.nextInt(1000), numBytes - read);
|
int chunk = Math.min(random.nextInt(1000), numBytes - read);
|
||||||
in.readBytes(verify, read, chunk);
|
in.readBytes(verify, read, chunk);
|
||||||
read += chunk;
|
read += chunk;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue