|
40 | 40 | import java.io.EOFException;
|
41 | 41 | import java.io.IOException;
|
42 | 42 | import java.util.Random;
|
| 43 | +import java.util.function.Supplier; |
43 | 44 | import org.apache.commons.lang3.tuple.Pair;
|
44 | 45 | import org.junit.jupiter.api.Test;
|
45 | 46 |
|
@@ -70,6 +71,38 @@ private static JBBPBitInputStream asInputStreamMSB0(final int... array) {
|
70 | 71 | JBBPBitOrder.MSB0);
|
71 | 72 | }
|
72 | 73 |
|
| 74 | + @Test |
| 75 | + public void testIsDetectedPartlyReadBitField() throws Exception { |
| 76 | + final Supplier<JBBPBitInputStream> oneByteStream = |
| 77 | + () -> new JBBPBitInputStream(new ByteArrayInputStream(new byte[] {1})); |
| 78 | + final Supplier<JBBPBitInputStream> oneByteStreamNoAccumulated = |
| 79 | + () -> new JBBPBitInputStream(new ByteArrayInputStream(new byte[] {1}), false); |
| 80 | + |
| 81 | + JBBPBitInputStream in = oneByteStream.get(); |
| 82 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 83 | + in.read(); |
| 84 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 85 | + |
| 86 | + in = oneByteStream.get(); |
| 87 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 88 | + in.readBits(BITS_1); |
| 89 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 90 | + in.read(); |
| 91 | + assertTrue(in.isDetectedPartlyReadBitField()); |
| 92 | + |
| 93 | + in = oneByteStreamNoAccumulated.get(); |
| 94 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 95 | + in.read(); |
| 96 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 97 | + |
| 98 | + in = oneByteStreamNoAccumulated.get(); |
| 99 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 100 | + in.readBits(BITS_1); |
| 101 | + assertFalse(in.isDetectedPartlyReadBitField()); |
| 102 | + in.read(); |
| 103 | + assertTrue(in.isDetectedPartlyReadBitField()); |
| 104 | + } |
| 105 | + |
73 | 106 | @Test
|
74 | 107 | public void testReadMsb0Direct() throws Exception {
|
75 | 108 | byte[] data = str2bin("00000001_101_00001000_00000_01_00_1011_00000");
|
|
0 commit comments