This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push: new a92bb6d2 Fix broken tests. a92bb6d2 is described below commit a92bb6d22fc70a7484e22f7c2ab52434b5accf13 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu May 5 15:36:51 2022 -0400 Fix broken tests. --- .../lz77support/AbstractLZ77CompressorInputStreamTest.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java index 50ed6a84..b5c4a9e6 100644 --- a/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java @@ -18,6 +18,10 @@ */ package org.apache.commons.compress.compressors.lz77support; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -25,16 +29,15 @@ import java.io.InputStream; import org.apache.commons.compress.utils.ByteUtils; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; - public class AbstractLZ77CompressorInputStreamTest { private static class TestStream extends AbstractLZ77CompressorInputStream { + private boolean literal; TestStream(final InputStream in) throws IOException { super(in, 1024); } + @Override public int read(final byte[] b, final int off, final int len) throws IOException { if (literal) { @@ -42,6 +45,7 @@ public class AbstractLZ77CompressorInputStreamTest { } return readBackReference(b, off, len); } + void literal(final int len) { startLiteral(len); literal = true; @@ -50,11 +54,11 @@ public class AbstractLZ77CompressorInputStreamTest { @Test public void cantPrefillAfterDataHasBeenRead() throws IOException { - final byte[] data = new byte[] { 1, 2, 3, 4 }; + final byte[] data = new byte[] {1, 2, 3, 4}; try (TestStream s = new TestStream(new ByteArrayInputStream(data))) { s.literal(3); assertEquals(1, s.read()); - s.prefill(new byte[] { 1, 2, 3 }); + assertThrows(IllegalArgumentException.class, () -> s.prefill(new byte[] {1, 2, 3})); } }