BlockEncoding blockEncoding = new RunLengthEncoder(sliceOutput, VARCHAR).append(expectedBlock).finish();
SliceInput sliceInput = sliceOutput.slice().getInput();
Block block = blockEncoding.readBlock(sliceInput);
assertInstanceOf(block, RunLengthEncodedBlock.class);
RunLengthEncodedBlock rleBlock = (RunLengthEncodedBlock) block;
assertTrue(positionEqualsPosition(VARCHAR, rleBlock, 0, expectedBlock, 0));
assertEquals(rleBlock.getPositionCount(), 2);
assertEquals(VARCHAR.getSlice(rleBlock, 0).toStringUtf8(), "alice");
block = blockEncoding.readBlock(sliceInput);
assertInstanceOf(block, RunLengthEncodedBlock.class);
rleBlock = (RunLengthEncodedBlock) block;
assertTrue(positionEqualsPosition(VARCHAR, rleBlock, 0, expectedBlock, 2));
assertEquals(rleBlock.getPositionCount(), 4);
assertEquals(VARCHAR.getSlice(rleBlock, 0).toStringUtf8(), "bob");
block = blockEncoding.readBlock(sliceInput);
assertInstanceOf(block, RunLengthEncodedBlock.class);
rleBlock = (RunLengthEncodedBlock) block;
assertTrue(positionEqualsPosition(VARCHAR, rleBlock, 0, expectedBlock, 6));
assertEquals(rleBlock.getPositionCount(), 6);
assertEquals(VARCHAR.getSlice(rleBlock, 0).toStringUtf8(), "charlie");
assertFalse(sliceInput.isReadable());
}