This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 9bcdc37f4c4b2a216782a0ce9ae3d048fce94214
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Jul 31 10:30:35 2026 -0400

    Sort members
---
 ...ctLhStaticHuffmanCompressorInputStreamTest.java | 118 ++++++++++-----------
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java
 
b/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java
index e8ea1d55d..83abe9f7a 100644
--- 
a/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java
@@ -32,6 +32,15 @@
 import org.junit.jupiter.api.Test;
 
 class AbstractLhStaticHuffmanCompressorInputStreamTest {
+    private Lh5CompressorInputStream createLh5CompressorInputStream(final 
int... data) throws IOException {
+        final byte[] bytes = new byte[data.length];
+        for (int i = 0; i < data.length; i++) {
+            bytes[i] = (byte) data[i];
+        }
+
+        return new Lh5CompressorInputStream(new ByteArrayInputStream(bytes));
+    }
+
     @Test
     void testInputStreamStatistics() throws IOException {
         final int[] compressedData = {
@@ -53,12 +62,41 @@ void testInputStreamStatistics() throws IOException {
     }
 
     @Test
-    void testReadCommandDecodingTreeWithSingleValue() throws IOException {
-        final BinaryTree tree = createLh5CompressorInputStream(
-            0b00000000, 0b00111111 // 5 bits length (0x00) and 5 bits the root 
value (0x00)
-        ).readCommandDecodingTree();
+    void testReadCodeLength() throws IOException {
+        assertEquals(0, createLh5CompressorInputStream(0x00, 
0x00).readCodeLength());  // 0000 0000  0000 0000
+        assertEquals(1, createLh5CompressorInputStream(0x20, 
0x00).readCodeLength());  // 0010 0000  0000 0000
+        assertEquals(2, createLh5CompressorInputStream(0x40, 
0x00).readCodeLength());  // 0100 0000  0000 0000
+        assertEquals(3, createLh5CompressorInputStream(0x60, 
0x00).readCodeLength());  // 0110 0000  0000 0000
+        assertEquals(4, createLh5CompressorInputStream(0x80, 
0x00).readCodeLength());  // 1000 0000  0000 0000
+        assertEquals(5, createLh5CompressorInputStream(0xa0, 
0x00).readCodeLength());  // 1010 0000  0000 0000
+        assertEquals(6, createLh5CompressorInputStream(0xc0, 
0x00).readCodeLength());  // 1100 0000  0000 0000
+        assertEquals(7, createLh5CompressorInputStream(0xe0, 
0x00).readCodeLength());  // 1110 0000  0000 0000
+        assertEquals(8, createLh5CompressorInputStream(0xf0, 
0x00).readCodeLength());  // 1111 0000  0000 0000
+        assertEquals(9, createLh5CompressorInputStream(0xf8, 
0x00).readCodeLength());  // 1111 1000  0000 0000
+        assertEquals(10, createLh5CompressorInputStream(0xfc, 
0x00).readCodeLength()); // 1111 1100  0000 0000
+        assertEquals(11, createLh5CompressorInputStream(0xfe, 
0x00).readCodeLength()); // 1111 1110  0000 0000
+        assertEquals(12, createLh5CompressorInputStream(0xff, 
0x00).readCodeLength()); // 1111 1111  0000 0000
+        assertEquals(13, createLh5CompressorInputStream(0xff, 
0x80).readCodeLength()); // 1111 1111  1000 0000
+        assertEquals(14, createLh5CompressorInputStream(0xff, 
0xc0).readCodeLength()); // 1111 1111  1100 0000
+        assertEquals(15, createLh5CompressorInputStream(0xff, 
0xe0).readCodeLength()); // 1111 1111  1110 0000
+        assertEquals(16, createLh5CompressorInputStream(0xff, 
0xf0).readCodeLength()); // 1111 1111  1111 0000
 
-        assertEquals(0, tree.read(new BitInputStream(new 
ByteArrayInputStream(new byte[0]), ByteOrder.BIG_ENDIAN)));
+        try {
+            createLh5CompressorInputStream(0xff, 0xf8).readCodeLength(); // 
1111 1111  1111 1000
+            fail("Expected CompressorException for code length overflow");
+        } catch (CompressorException e) {
+            assertEquals("Code length overflow", e.getMessage());
+        }
+    }
+
+    @Test
+    void testReadCodeLengthUnexpectedEndOfStream() throws IOException {
+        try {
+            createLh5CompressorInputStream(0xff).readCodeLength(); // 1111 
1111  EOF
+            fail("Expected CompressorException for unexpected end of stream");
+        } catch (CompressorException e) {
+            assertEquals("Unexpected end of stream", e.getMessage());
+        }
     }
 
     @Test
@@ -75,25 +113,12 @@ void testReadCommandDecodingTreeWithInvalidSize() throws 
IOException {
     }
 
     @Test
-    void testReadCommandTreeWithSingleValue() throws IOException {
+    void testReadCommandDecodingTreeWithSingleValue() throws IOException {
         final BinaryTree tree = createLh5CompressorInputStream(
-            0b00000000, 0b01111111, 0b01000000 // 9 bits length (0x00) and 9 
bits the root value (0x01fd = 509)
-        ).readCommandTree(new BinaryTree(new int [] { 0 }));
-
-        assertEquals(0x01fd, tree.read(new BitInputStream(new 
ByteArrayInputStream(new byte[0]), ByteOrder.BIG_ENDIAN)));
-    }
-
-    @Test
-    void testReadCommandTreeWithInvalidSize() throws IOException {
-        try {
-            createLh5CompressorInputStream(
-                0b11111111, 0b10000000 // 9 bits length (0x01ff = 511)
-            ).readCommandTree(new BinaryTree(new int [] { 0 }));
+            0b00000000, 0b00111111 // 5 bits length (0x00) and 5 bits the root 
value (0x00)
+        ).readCommandDecodingTree();
 
-            fail("Expected CompressorException for table invalid size");
-        } catch (CompressorException e) {
-            assertEquals("Code length table has invalid size (511 > 510)", 
e.getMessage());
-        }
+        assertEquals(0, tree.read(new BitInputStream(new 
ByteArrayInputStream(new byte[0]), ByteOrder.BIG_ENDIAN)));
     }
 
     @Test
@@ -109,49 +134,24 @@ void testReadCommandTreeUnexpectedEndOfStream() throws 
IOException {
     }
 
     @Test
-    void testReadCodeLength() throws IOException {
-        assertEquals(0, createLh5CompressorInputStream(0x00, 
0x00).readCodeLength());  // 0000 0000  0000 0000
-        assertEquals(1, createLh5CompressorInputStream(0x20, 
0x00).readCodeLength());  // 0010 0000  0000 0000
-        assertEquals(2, createLh5CompressorInputStream(0x40, 
0x00).readCodeLength());  // 0100 0000  0000 0000
-        assertEquals(3, createLh5CompressorInputStream(0x60, 
0x00).readCodeLength());  // 0110 0000  0000 0000
-        assertEquals(4, createLh5CompressorInputStream(0x80, 
0x00).readCodeLength());  // 1000 0000  0000 0000
-        assertEquals(5, createLh5CompressorInputStream(0xa0, 
0x00).readCodeLength());  // 1010 0000  0000 0000
-        assertEquals(6, createLh5CompressorInputStream(0xc0, 
0x00).readCodeLength());  // 1100 0000  0000 0000
-        assertEquals(7, createLh5CompressorInputStream(0xe0, 
0x00).readCodeLength());  // 1110 0000  0000 0000
-        assertEquals(8, createLh5CompressorInputStream(0xf0, 
0x00).readCodeLength());  // 1111 0000  0000 0000
-        assertEquals(9, createLh5CompressorInputStream(0xf8, 
0x00).readCodeLength());  // 1111 1000  0000 0000
-        assertEquals(10, createLh5CompressorInputStream(0xfc, 
0x00).readCodeLength()); // 1111 1100  0000 0000
-        assertEquals(11, createLh5CompressorInputStream(0xfe, 
0x00).readCodeLength()); // 1111 1110  0000 0000
-        assertEquals(12, createLh5CompressorInputStream(0xff, 
0x00).readCodeLength()); // 1111 1111  0000 0000
-        assertEquals(13, createLh5CompressorInputStream(0xff, 
0x80).readCodeLength()); // 1111 1111  1000 0000
-        assertEquals(14, createLh5CompressorInputStream(0xff, 
0xc0).readCodeLength()); // 1111 1111  1100 0000
-        assertEquals(15, createLh5CompressorInputStream(0xff, 
0xe0).readCodeLength()); // 1111 1111  1110 0000
-        assertEquals(16, createLh5CompressorInputStream(0xff, 
0xf0).readCodeLength()); // 1111 1111  1111 0000
-
+    void testReadCommandTreeWithInvalidSize() throws IOException {
         try {
-            createLh5CompressorInputStream(0xff, 0xf8).readCodeLength(); // 
1111 1111  1111 1000
-            fail("Expected CompressorException for code length overflow");
-        } catch (CompressorException e) {
-            assertEquals("Code length overflow", e.getMessage());
-        }
-    }
+            createLh5CompressorInputStream(
+                0b11111111, 0b10000000 // 9 bits length (0x01ff = 511)
+            ).readCommandTree(new BinaryTree(new int [] { 0 }));
 
-    @Test
-    void testReadCodeLengthUnexpectedEndOfStream() throws IOException {
-        try {
-            createLh5CompressorInputStream(0xff).readCodeLength(); // 1111 
1111  EOF
-            fail("Expected CompressorException for unexpected end of stream");
+            fail("Expected CompressorException for table invalid size");
         } catch (CompressorException e) {
-            assertEquals("Unexpected end of stream", e.getMessage());
+            assertEquals("Code length table has invalid size (511 > 510)", 
e.getMessage());
         }
     }
 
-    private Lh5CompressorInputStream createLh5CompressorInputStream(final 
int... data) throws IOException {
-        final byte[] bytes = new byte[data.length];
-        for (int i = 0; i < data.length; i++) {
-            bytes[i] = (byte) data[i];
-        }
+    @Test
+    void testReadCommandTreeWithSingleValue() throws IOException {
+        final BinaryTree tree = createLh5CompressorInputStream(
+            0b00000000, 0b01111111, 0b01000000 // 9 bits length (0x00) and 9 
bits the root value (0x01fd = 509)
+        ).readCommandTree(new BinaryTree(new int [] { 0 }));
 
-        return new Lh5CompressorInputStream(new ByteArrayInputStream(bytes));
+        assertEquals(0x01fd, tree.read(new BitInputStream(new 
ByteArrayInputStream(new byte[0]), ByteOrder.BIG_ENDIAN)));
     }
 }

Reply via email to