57 test01Int8BitsAlignedImpl((
byte)0);
58 test01Int8BitsAlignedImpl((
byte)1);
59 test01Int8BitsAlignedImpl((
byte)7);
60 test01Int8BitsAlignedImpl(Byte.MIN_VALUE);
61 test01Int8BitsAlignedImpl(Byte.MAX_VALUE);
62 test01Int8BitsAlignedImpl((
byte)0xff);
64 void test01Int8BitsAlignedImpl(
final byte val8)
throws IOException {
67 System.err.println(
"XXX Test01Int8BitsAligned: value "+val8+
", "+toHexBinaryString(val8, 8));
74 System.err.println(
"Read8.1 "+r8+
", "+toHexBinaryString(r8, 8));
75 Assert.assertEquals(val8, r8);
84 System.err.println(
"Read8.2 "+r8+
", "+toHexBinaryString(r8, 8));
85 Assert.assertEquals(val8, r8);
91 test02Int8BitsUnalignedImpl(0);
92 test02Int8BitsUnalignedImpl(1);
93 test02Int8BitsUnalignedImpl(7);
94 test02Int8BitsUnalignedImpl(8);
95 test02Int8BitsUnalignedImpl(15);
96 test02Int8BitsUnalignedImpl(24);
97 test02Int8BitsUnalignedImpl(25);
99 void test02Int8BitsUnalignedImpl(
final int preBits)
throws IOException {
100 test02Int8BitsUnalignedImpl(preBits, (
byte)0);
101 test02Int8BitsUnalignedImpl(preBits, (
byte)1);
102 test02Int8BitsUnalignedImpl(preBits, (
byte)7);
103 test02Int8BitsUnalignedImpl(preBits, Byte.MIN_VALUE);
104 test02Int8BitsUnalignedImpl(preBits, Byte.MAX_VALUE);
105 test02Int8BitsUnalignedImpl(preBits, (
byte)0xff);
107 void test02Int8BitsUnalignedImpl(
final int preBits,
final byte val8)
throws IOException {
108 final int preBytes = ( preBits + 7 ) >>> 3;
109 final int byteCount = preBytes + Buffers.SIZEOF_BYTE;
110 final ByteBuffer bb = ByteBuffer.allocate(byteCount);
111 System.err.println(
"XXX Test02Int8BitsUnaligned: preBits "+preBits+
", value "+val8+
", "+toHexBinaryString(val8, 8));
114 final Bitstream.ByteBufferStream bbs =
new Bitstream.ByteBufferStream(bb);
115 final Bitstream<ByteBuffer> bs =
new Bitstream<ByteBuffer>(bbs,
true );
116 bs.writeBits31(preBits, 0);
118 bs.setStream(bs.getSubStream(),
false );
120 final int rPre = (short) bs.readBits31(preBits);
121 final byte r8 = (byte) bs.readUInt8();
122 System.err.println(
"ReadPre "+rPre+
", "+toBinaryString(rPre, preBits));
123 System.err.println(
"Read8 "+r8+
", "+toHexBinaryString(r8, 8));
124 Assert.assertEquals(val8, r8);
127 public static void main(
final String args[])
throws IOException {
129 org.junit.runner.JUnitCore.
main(tstname);