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

commit 927090ac4aaf8967d0e75367353c100c1e6f875b
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Apr 13 16:23:13 2025 -0400

    Sort members
---
 .../commons/compress/utils/BitInputStreamTest.java | 66 +++++++++++-----------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java 
b/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java
index 269868c72..fc1ddb1a2 100644
--- a/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java
@@ -199,16 +199,37 @@ public void testReading31BitsInLittleEndian() throws 
IOException {
     }
 
     @Test
-    public void testShouldNotAllowReadingOfANegativeAmountOfBits() throws 
IOException {
-        try (BitInputStream bis = new BitInputStream(getStream(), 
ByteOrder.LITTLE_ENDIAN)) {
-            assertThrows(IOException.class, () -> bis.readBits(-1));
+    public void testReadingOneBitFromEmptyStream() throws Exception {
+        try (BitInputStream bis = new BitInputStream(new 
ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), ByteOrder.LITTLE_ENDIAN)) {
+            assertEquals(-1, bis.readBit(), "next bit");
+            assertEquals(-1, bis.readBit(), "next bit");
+            assertEquals(-1, bis.readBit(), "next bit");
         }
     }
 
     @Test
-    public void testShouldNotAllowReadingOfMoreThan63BitsAtATime() throws 
IOException {
-        try (BitInputStream bis = new BitInputStream(getStream(), 
ByteOrder.LITTLE_ENDIAN)) {
-            assertThrows(IOException.class, () -> bis.readBits(64));
+    public void testReadingOneBitInBigEndian() throws Exception {
+        try (BitInputStream bis = new BitInputStream(new 
ByteArrayInputStream(new byte[] { (byte) 0xEA, 0x03 }), ByteOrder.BIG_ENDIAN)) {
+
+            assertEquals(1, bis.readBit(), "bit 0");
+            assertEquals(1, bis.readBit(), "bit 1");
+            assertEquals(1, bis.readBit(), "bit 2");
+            assertEquals(0, bis.readBit(), "bit 3");
+            assertEquals(1, bis.readBit(), "bit 4");
+            assertEquals(0, bis.readBit(), "bit 5");
+            assertEquals(1, bis.readBit(), "bit 6");
+            assertEquals(0, bis.readBit(), "bit 7");
+
+            assertEquals(0, bis.readBit(), "bit 8");
+            assertEquals(0, bis.readBit(), "bit 9");
+            assertEquals(0, bis.readBit(), "bit 10");
+            assertEquals(0, bis.readBit(), "bit 11");
+            assertEquals(0, bis.readBit(), "bit 12");
+            assertEquals(0, bis.readBit(), "bit 13");
+            assertEquals(1, bis.readBit(), "bit 14");
+            assertEquals(1, bis.readBit(), "bit 15");
+
+            assertEquals(-1, bis.readBit(), "next bit");
         }
     }
 
@@ -239,37 +260,16 @@ public void testReadingOneBitInLittleEndian() throws 
Exception {
     }
 
     @Test
-    public void testReadingOneBitInBigEndian() throws Exception {
-        try (BitInputStream bis = new BitInputStream(new 
ByteArrayInputStream(new byte[] { (byte) 0xEA, 0x03 }), ByteOrder.BIG_ENDIAN)) {
-
-            assertEquals(1, bis.readBit(), "bit 0");
-            assertEquals(1, bis.readBit(), "bit 1");
-            assertEquals(1, bis.readBit(), "bit 2");
-            assertEquals(0, bis.readBit(), "bit 3");
-            assertEquals(1, bis.readBit(), "bit 4");
-            assertEquals(0, bis.readBit(), "bit 5");
-            assertEquals(1, bis.readBit(), "bit 6");
-            assertEquals(0, bis.readBit(), "bit 7");
-
-            assertEquals(0, bis.readBit(), "bit 8");
-            assertEquals(0, bis.readBit(), "bit 9");
-            assertEquals(0, bis.readBit(), "bit 10");
-            assertEquals(0, bis.readBit(), "bit 11");
-            assertEquals(0, bis.readBit(), "bit 12");
-            assertEquals(0, bis.readBit(), "bit 13");
-            assertEquals(1, bis.readBit(), "bit 14");
-            assertEquals(1, bis.readBit(), "bit 15");
-
-            assertEquals(-1, bis.readBit(), "next bit");
+    public void testShouldNotAllowReadingOfANegativeAmountOfBits() throws 
IOException {
+        try (BitInputStream bis = new BitInputStream(getStream(), 
ByteOrder.LITTLE_ENDIAN)) {
+            assertThrows(IOException.class, () -> bis.readBits(-1));
         }
     }
 
     @Test
-    public void testReadingOneBitFromEmptyStream() throws Exception {
-        try (BitInputStream bis = new BitInputStream(new 
ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), ByteOrder.LITTLE_ENDIAN)) {
-            assertEquals(-1, bis.readBit(), "next bit");
-            assertEquals(-1, bis.readBit(), "next bit");
-            assertEquals(-1, bis.readBit(), "next bit");
+    public void testShouldNotAllowReadingOfMoreThan63BitsAtATime() throws 
IOException {
+        try (BitInputStream bis = new BitInputStream(getStream(), 
ByteOrder.LITTLE_ENDIAN)) {
+            assertThrows(IOException.class, () -> bis.readBits(64));
         }
     }
 

Reply via email to