Add unit test for FakeDataSource.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163341994
This commit is contained in:
tonihei 2017-07-27 08:15:15 -07:00 committed by Oliver Woodman
parent 84d19c464b
commit ad5ca0812d
2 changed files with 3 additions and 2 deletions

View File

@ -162,8 +162,8 @@ public class FakeDataSet {
}
/**
* Appends data of the specified length. No actual data is available and this data should not
* be read.
* Appends a data segment of the specified length. No actual data is available and the
* {@link FakeDataSource} will perform no copy operations when this data is read.
*/
public FakeData appendReadData(int length) {
Assertions.checkState(length > 0);

View File

@ -166,6 +166,7 @@ public class FakeDataSource implements DataSource {
// Do not allow crossing of the segment boundary.
readLength = Math.min(readLength, current.length - current.bytesRead);
// Perform the read and return.
Assertions.checkArgument(buffer.length - offset >= readLength);
if (current.data != null) {
System.arraycopy(current.data, current.bytesRead, buffer, offset, readLength);
}