Package com.peterhi.runtime

Examples of com.peterhi.runtime.BitStream.bytes()


    assertEquals(2, bs.readBits(8, true).byteValue());
    assertEquals(-1, bs.readBit());
    bs.clearReadMark();
    assertEquals(-1, bs.readBit());
    assertEquals(0, bs.available());
    assertEquals(2, bs.bytes());
    bs.goToReadFromBeginning();
    assertEquals(1, bs.readBits(8, true).byteValue());
    assertEquals(2, bs.readBits(8, true).byteValue());
  }
 
View Full Code Here


    BitStream bs = new BitStream(2);
    bs.writeBits(BigInteger.ONE, 8);
    bs.setWriteMark();
    bs.writeBits(BigInteger.TEN, 8);
    assertEquals(Byte.SIZE * 2, bs.available());
    assertEquals(2, bs.bytes());
    byte[] data = bs.toByteArray();
    assertEquals(2, data.length);
    assertEquals(1, data[0]);
    assertEquals(10, data[1]);
    bs.goToWriteMark();
View Full Code Here

    assertEquals(1, data[0]);
    assertEquals(10, data[1]);
    bs.goToWriteMark();
    bs.writeBits(BigInteger.ZERO, 8);
    assertEquals(Byte.SIZE * 2, bs.available());
    assertEquals(2, bs.bytes());
    data = bs.toByteArray();
    assertEquals(2, data.length);
    assertEquals(1, data[0]);
    assertEquals(0, data[1]);
    bs.clearWriteMark();
View Full Code Here

    bs.clearWriteMark();
    bs.writeBits(BigInteger.TEN, 8);
    data = bs.toByteArray();
    assertEquals(3, data.length);
    assertEquals(Byte.SIZE * 3, bs.available());
    assertEquals(130, bs.bytes());
    bs.goToWriteFromBeginning();
    bs.writeBits(BigInteger.ZERO, 8);
    bs.writeBits(BigInteger.ZERO, 8);
    data = bs.toByteArray();
    assertEquals(0, data[0]);
View Full Code Here

    bs.writeBit(1);
    byte[] data = bs.toByteArray();
    assertEquals(1, data[0]);
    assertEquals(1, data[1]);
    assertEquals(9, bs.available());
    assertEquals(2, bs.bytes());
  }
 
  @Test
  public void testAlignRead() throws Exception {
    BitStream bs = new BitStream(new byte[] { 1, 1 }, 0, Byte.SIZE * 2);
 
View Full Code Here

    BitStream bs = new BitStream(new byte[] { 1, 1 }, 0, Byte.SIZE * 2);
    assertEquals(1, bs.readBit());
    bs.alignRead();
    assertEquals(1, bs.readBit());
    assertEquals(7, bs.available());
    assertEquals(2, bs.bytes());
  }
 
  @Test
  public void testToByteArray() throws Exception {
    BitStream bs = new BitStream(2);
View Full Code Here

    bs.readBits(4, true);
    data = bs.toByteArray();
    assertEquals(-1, data[0]);
    assertEquals(15, data[1]);
    assertEquals(12, bs.available());
    assertEquals(2, bs.bytes());
  }
 
  @Test
  public void testClear() throws Exception {
    BitStream bs = new BitStream(2);
View Full Code Here

    bs.writeBit(1);
    assertEquals(1, bs.readBit());
    bs.clear();
    assertEquals(-1, bs.readBit());
    assertEquals(0, bs.available());
    assertEquals(2, bs.bytes());
    bs.writeBit(1);
    byte[] data = bs.toByteArray();
    assertEquals(1, data[0]);
    assertEquals(1, bs.available());
    assertEquals(2, bs.bytes());
View Full Code Here

    assertEquals(2, bs.bytes());
    bs.writeBit(1);
    byte[] data = bs.toByteArray();
    assertEquals(1, data[0]);
    assertEquals(1, bs.available());
    assertEquals(2, bs.bytes());
  }
 
  @Test
  public void testSkipWrite() throws Exception {
    BitStream bs0 = new BitStream(1);
View Full Code Here

  @Test
  public void testConstructorCapacity() throws Exception {
    {
      BitStream bs = new BitStream(32);
      assertEquals(0, bs.available());
      assertEquals(32, bs.bytes());
    }
   
    try {
      BitStream bs = new BitStream(-1);
      fail();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.