move method only used in tests to the tests

This commit is contained in:
2018-10-13 20:03:02 +02:00
parent b42fec8fe2
commit a2520c0238
2 changed files with 13 additions and 14 deletions

View File

@@ -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;
}
}