Package com.peterhi.runtime

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


    {
      byte[] data = new byte[] { (byte )170, (byte )85 };
      BitStream bs = new BitStream(data, 0, Byte.SIZE * data.length);
     
      for (int i = 0; i < Byte.SIZE; i++) {
        int bit = bs.readBit();
       
        if (i % 2 == 0) {
          assertEquals(0, bit);
        } else {
          assertEquals(1, bit);
View Full Code Here


          assertEquals(1, bit);
        }
      }
     
      for (int i = 0; i < Byte.SIZE; i++) {
        int bit = bs.readBit();
       
        if (i % 2 == 0) {
          assertEquals(1, bit);
        } else {
          assertEquals(0, bit);
View Full Code Here

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

     
      assertEquals(10, bs.available());
      assertEquals(129, bs.bytes());
     
      for (int i = 0; i < 10; i++) {
        assertEquals(i % 2, bs.readBit());
      }
     
      assertEquals(0, bs.available());
      assertEquals(129, bs.bytes());
      assertEquals(-1, bs.readBit());
View Full Code Here

        assertEquals(i % 2, bs.readBit());
      }
     
      assertEquals(0, bs.available());
      assertEquals(129, bs.bytes());
      assertEquals(-1, bs.readBit());
    }
  }
 
  @Test
  public void testReadBits() throws Exception {
View Full Code Here

  public void testReadMarks() throws Exception {
    BitStream bs = new BitStream(new byte[] { 1, 2 }, 0, Byte.SIZE * 2);
    assertEquals(1, bs.readBits(8, true).byteValue());
    bs.setReadMark();
    assertEquals(2, bs.readBits(8, true).byteValue());
    assertEquals(-1, bs.readBit());
    bs.goToReadMark();
    assertEquals(2, bs.readBits(8, true).byteValue());
    assertEquals(-1, bs.readBit());
    bs.clearReadMark();
    assertEquals(-1, bs.readBit());
View Full Code Here

    bs.setReadMark();
    assertEquals(2, bs.readBits(8, true).byteValue());
    assertEquals(-1, bs.readBit());
    bs.goToReadMark();
    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();
View Full Code Here

    assertEquals(-1, bs.readBit());
    bs.goToReadMark();
    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

  }
 
  @Test
  public void testAlignRead() throws Exception {
    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());
  }
View Full Code Here

  @Test
  public void testAlignRead() throws Exception {
    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
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.