move method only used in tests to the tests
This commit is contained in:
@@ -46,7 +46,7 @@ public class DiskStorageTest {
|
||||
try (DiskStorage ds = new DiskStorage(databaseFile)) {
|
||||
final int numBlocks = 10;
|
||||
|
||||
ds.allocateBlocks(numBlocks, BLOCK_SIZE);
|
||||
allocateBlocks(ds, numBlocks, BLOCK_SIZE);
|
||||
final List<DiskBlock> blocks = new ArrayList<>();
|
||||
|
||||
// fill the first 16 512-byte blocks
|
||||
@@ -101,7 +101,7 @@ public class DiskStorageTest {
|
||||
try (DiskStorage ds = new DiskStorage(databaseFile)) {
|
||||
final int numBlocks = 10;
|
||||
|
||||
final long[] blockOffsets = ds.allocateBlocks(numBlocks, BLOCK_SIZE);
|
||||
final long[] blockOffsets = allocateBlocks(ds, numBlocks, BLOCK_SIZE);
|
||||
|
||||
for (final long blockOffset : blockOffsets) {
|
||||
|
||||
@@ -292,4 +292,15 @@ public class DiskStorageTest {
|
||||
buffer[i] = val;
|
||||
}
|
||||
}
|
||||
|
||||
private long[] allocateBlocks(final DiskStorage ds, final int numNewBlocks, final int blockSize)
|
||||
throws IOException {
|
||||
|
||||
final long[] result = new long[numNewBlocks];
|
||||
for (int i = 0; i < numNewBlocks; i++) {
|
||||
final long blockOffset = ds.allocateBlock(blockSize);
|
||||
result[i] = blockOffset;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user