Package com.peterhi.runtime

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


   
    {
      BitStream bs = new BitStream(1);
     
      for (int i = 0; i < 9; i++) {
        bs.writeBit(1);
      }
     
      assertEquals(9, bs.available());
      assertEquals(129, bs.bytes());
    }
View Full Code Here


  public void testWriteBit() throws Exception {
    {
      BitStream bs = new BitStream(1);
     
      for (int i = 0; i < 10; i++) {
        bs.writeBit(i % 2);
      }
     
      assertEquals(10, bs.available());
      assertEquals(129, bs.bytes());
     
View Full Code Here

    } catch (EOFException ex) {
    }
   
    try {
      BitStream bs = new BitStream(32);
      bs.writeBit(1);
      bs.readBits(2, true);
      fail();
    } catch (InsufficientBufferException ex) {
    }
  }
View Full Code Here

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

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

  }
 
  @Test
  public void testClear() throws Exception {
    BitStream bs = new BitStream(2);
    bs.writeBit(1);
    bs.alignRead();
    bs.writeBit(0);
    bs.writeBit(1);
    assertEquals(1, bs.readBit());
    bs.clear();
View Full Code Here

  @Test
  public void testClear() throws Exception {
    BitStream bs = new BitStream(2);
    bs.writeBit(1);
    bs.alignRead();
    bs.writeBit(0);
    bs.writeBit(1);
    assertEquals(1, bs.readBit());
    bs.clear();
    assertEquals(-1, bs.readBit());
    assertEquals(0, bs.available());
View Full Code Here

  public void testClear() throws Exception {
    BitStream bs = new BitStream(2);
    bs.writeBit(1);
    bs.alignRead();
    bs.writeBit(0);
    bs.writeBit(1);
    assertEquals(1, bs.readBit());
    bs.clear();
    assertEquals(-1, bs.readBit());
    assertEquals(0, bs.available());
    assertEquals(2, bs.bytes());
View Full Code Here

    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

  }
 
  @Test
  public void testSkipWrite() throws Exception {
    BitStream bs0 = new BitStream(1);
    bs0.writeBit(1);
    bs0.alignWrite();
    bs0.writeBit(1);
    BitStream bs1 = new BitStream(1);
    bs1.writeBit(1);
    bs1.skipWrite(7);
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.