fix(cbx): use natural compare that handles numbers larger than int (#2536)

This commit is contained in:
James Ward
2026-09-09 00:46:08 -04:00
committed by GitHub
parent 53abc8bf81
commit 11224eb9ce
2 changed files with 120 additions and 23 deletions
@@ -1037,6 +1037,36 @@ class CbxMetadataExtractorTest {
assertThat(cover).isNull();
}
@Test
void extractsCoverWithNaturalNumberComparisons() throws IOException {
byte[] expected = createMinimalJpeg(1);
Path cbzPath = mockArchiveContents(Map.of(
"img_000002.jpg", createMinimalJpeg(2),
"img_0001.jpg", expected,
"img_003.jpg", createMinimalJpeg(3)
));
byte[] actual = extractor.extractCover(cbzPath);
assertThat(actual).isEqualTo(expected);
}
@Test
void extractsCoverWithBigIntegerNumbers() throws IOException {
byte[] expected = createMinimalJpeg(1);
Path cbzPath = mockArchiveContents(Map.of(
"9789031433940_002.jpg", createMinimalJpeg(3),
"9789031433940_000.jpg", expected,
"9789031433940_001.jpg", createMinimalJpeg(2)
));
byte[] actual = extractor.extractCover(cbzPath);
assertThat(actual).isEqualTo(expected);
}
}
@Nested