@Test
public void testListEntries() throws IOException {

  // Ensure all entries are found, and that they are in file order.
  List<MinimalZipEntry> parsedEntries = MinimalZipArchive.listEntries(tempFile);
  long lastSeenHeaderOffset = -1;
  for (int x = 0; x < UnitTestZipArchive.allEntriesInFileOrder.size(); x++) {
    UnitTestZipEntry expected = UnitTestZipArchive.allEntriesInFileOrder.get(x);
    MinimalZipEntry actual = parsedEntries.get(x);
    Assert.assertEquals(expected.path, actual.getFileName());
    Assert.assertEquals(expected.level == 0 ? 0 : 8, actual.getCompressionMethod());
    Assert.assertEquals(expected.getCompressedBinaryContent().length, actual.getCompressedSize());
    Assert.assertEquals(
        expected.getUncompressedBinaryContent().length, actual.getUncompressedSize());
    Assert.assertEquals(false, actual.getGeneralPurposeFlagBit11());
    CRC32 crc32 = new CRC32();
    crc32.update(expected.getUncompressedBinaryContent());
    Assert.assertEquals(crc32.getValue(), actual.getCrc32OfUncompressedData());
    // Offset verification is a little trickier
    // 1. Verify that the offsets are in ascending order and increasing.
    Assert.assertTrue(actual.getFileOffsetOfLocalEntry() > lastSeenHeaderOffset);
    lastSeenHeaderOffset = actual.getFileOffsetOfLocalEntry();
    // 2. Verify that the local signature header is at the calculated position
    byte[] expectedSignatureBlock = new byte[] {0x50, 0x4b, 0x03, 0x04};
    for (int index = 0; index < 4; index++) {
      byte actualByte = unitTestZipArchive[((int) actual.getFileOffsetOfLocalEntry()) + index];
      Assert.assertEquals(expectedSignatureBlock[index], actualByte);
    }
    // 3. Verify that the data is at the calculated position
    byte[] expectedContent = expected.getCompressedBinaryContent();
    int calculatedDataOffset = (int) actual.getFileOffsetOfCompressedData();
    for (int index = 0; index < expectedContent.length; index++) {
      Assert.assertEquals(
          expectedContent[index], unitTestZipArchive[calculatedDataOffset + index]);
    }
  }
}