Add unit test for FakeDataSource.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=163341994
This commit is contained in:
parent
84d19c464b
commit
ad5ca0812d
@ -162,8 +162,8 @@ public class FakeDataSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends data of the specified length. No actual data is available and this data should not
|
* Appends a data segment of the specified length. No actual data is available and the
|
||||||
* be read.
|
* {@link FakeDataSource} will perform no copy operations when this data is read.
|
||||||
*/
|
*/
|
||||||
public FakeData appendReadData(int length) {
|
public FakeData appendReadData(int length) {
|
||||||
Assertions.checkState(length > 0);
|
Assertions.checkState(length > 0);
|
||||||
|
@ -166,6 +166,7 @@ public class FakeDataSource implements DataSource {
|
|||||||
// Do not allow crossing of the segment boundary.
|
// Do not allow crossing of the segment boundary.
|
||||||
readLength = Math.min(readLength, current.length - current.bytesRead);
|
readLength = Math.min(readLength, current.length - current.bytesRead);
|
||||||
// Perform the read and return.
|
// Perform the read and return.
|
||||||
|
Assertions.checkArgument(buffer.length - offset >= readLength);
|
||||||
if (current.data != null) {
|
if (current.data != null) {
|
||||||
System.arraycopy(current.data, current.bytesRead, buffer, offset, readLength);
|
System.arraycopy(current.data, current.bytesRead, buffer, offset, readLength);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user