test: 减少测试时处理的数据量

This commit is contained in:
2025-10-14 02:37:03 +08:00
parent a65af967cb
commit fafb26fcf7
3 changed files with 7 additions and 9507 deletions

View File

@@ -73,11 +73,11 @@ public class ZipTools {
if (input == null) {
return null;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater(level))) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (DeflaterOutputStream dos = new DeflaterOutputStream(out, new Deflater(level))) {
dos.write(input);
dos.finish();
return baos.toByteArray();
return out.toByteArray();
}
}
@@ -94,11 +94,11 @@ public class ZipTools {
if (input == null) {
return null;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (InflaterOutputStream dos = new InflaterOutputStream(baos, new Inflater())) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (InflaterOutputStream dos = new InflaterOutputStream(out, new Inflater())) {
dos.write(input);
dos.finish();
return baos.toByteArray();
return out.toByteArray();
}
}

View File

@@ -61,7 +61,7 @@ public class ZipToolsTests {
}
@Test
void zip_WithWrongLevel() throws IOException, DataFormatException {
void zip_WithWrongLevel() {
Random random = new Random();
final int levelGtMax = random.nextInt() + 9;
assertThrows(IllegalArgumentException.class, () -> ZipTools.zip(bytes, levelGtMax));