### Question:
BitStream { public void write(int n, long v) { if (n < 1 || n > 64) { throw new IllegalArgumentException( String.format("Unable to write %s bits to value %d", n, v)); } reserve(n); long v1 = v << 64 - n >>> shift; data[index] = data[index] | v1; shift += n; if (shift >= 64) { shift -= 64; index++; if (shift != 0) { long v2 = v << 64 - shift; data[index] = data[index] | v2; } } } BitStream();  BitStream(int initialCapacity);  BitStream(long[] data, int len, int index, byte shift); void write(int n, long v); Map<String, Double> getStats(); BitStreamIterator read(); static BitStream deserialize(ByteBuffer buffer); void serialize(ByteBuffer buffer); int getSerializedByteSize();  }### Answer:
@Test public void testNegativeBitEncoding() { thrown.expect(IllegalArgumentException.class); new BitStream( 2).write(-1, 10); }
@Test public void testZeroBitEncoding() { thrown.expect(IllegalArgumentException.class); new BitStream( 2).write(0, 10); }
@Test public void test9ByteEncoding() { thrown.expect(IllegalArgumentException.class); new BitStream( 2).write(65, 10); }