122123124125126127128129130131132
} { byte[] data = new byte[32]; BitStream bs = new BitStream(data, Byte.SIZE * 16, Byte.SIZE * 16); assertEquals(Byte.SIZE * 16, bs.available()); assertEquals(16, bs.bytes()); } { BitStream bs = new BitStream(1);
133134135136137138139140141142143
for (int i = 0; i < 9; i++) { bs.writeBit(1); } assertEquals(9, bs.available()); assertEquals(129, bs.bytes()); } } @Test
164165166167168169170171172173174
} else { assertEquals(0, bit); } } assertEquals(0, bs.available()); assertEquals(2, bs.bytes()); } { BitStream bs = new BitStream(32);
170171172173174175176177178179180
assertEquals(2, bs.bytes()); } { BitStream bs = new BitStream(32); assertEquals(0, bs.available()); assertEquals(32, bs.bytes()); assertEquals(-1, bs.readBit()); } }
185186187188189190191192193194195
for (int i = 0; i < 10; i++) { bs.writeBit(i % 2); } assertEquals(10, bs.available()); assertEquals(129, bs.bytes()); for (int i = 0; i < 10; i++) { assertEquals(i % 2, bs.readBit()); }
192193194195196197198199200201202
for (int i = 0; i < 10; i++) { assertEquals(i % 2, bs.readBit()); } assertEquals(0, bs.available()); assertEquals(129, bs.bytes()); assertEquals(-1, bs.readBit()); } }
242243244245246247248249250251252
} else if (size == Long.SIZE) { assertEquals(number.longValue(), bs.readBits(size, true).longValue()); } } assertEquals(0, bs.available()); assertEquals(bytesWritten, bs.bytes()); } try { BitStream bs = new BitStream(32);
283284285286287288289290291292293
if (size == Byte.SIZE || size == Short.SIZE || size == Integer.SIZE || size == Long.SIZE) { bs.writeBits(number, size); } } assertEquals(Byte.SIZE * 60, bs.available()); assertEquals(60, bs.bytes()); byte[] data = bs.toByteArray(); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data));
333334335336337338339340341342343
Integer size = entry.getValue(); bsw.writeBits(number, size); bitsWritten += size; } assertEquals(bitsWritten, bsw.available()); assertEquals(548, bsw.bytes()); byte[] data = bsw.toByteArray(); BitStream bsr = new BitStream(data, 0, bitsWritten);
353354355356357358359360361362363
} assertEquals(number.and(mask), value.and(mask)); } assertEquals(0, bsr.available()); assertEquals(548, bsr.bytes()); } @Test public void testReadMarks() throws Exception {