Package com.peterhi.runtime

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


   
    {
      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);
     
View Full Code Here


      for (int i = 0; i < 9; i++) {
        bs.writeBit(1);
      }
     
      assertEquals(9, bs.available());
      assertEquals(129, bs.bytes());
    }
  }
 
  @Test
  public void testReadBit() throws Exception {
View Full Code Here

          assertEquals(0, bit);
        }
      }
     
      assertEquals(0, bs.available());
      assertEquals(2, bs.bytes());
    }
   
    {
      BitStream bs = new BitStream(32);
      assertEquals(0, bs.available());
View Full Code Here

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

      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());
      }
     
View Full Code Here

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

          assertEquals(number.longValue(), bs.readBits(size, true).longValue());
        }
      }
     
      assertEquals(0, bs.available());
      assertEquals(bytesWritten, bs.bytes());
    }
   
    try {
      BitStream bs = new BitStream(32);
      bs.readBits(-1, true);
View Full Code Here

          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));
     
      for (Map.Entry<BigInteger, Integer> entry : numbers.entrySet()) {
View Full Code Here

      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);
   
    for (Map.Entry<BigInteger, Integer> entry : numbers.entrySet()) {
View Full Code Here

     
      assertEquals(number.and(mask), value.and(mask));
    }
   
    assertEquals(0, bsr.available());
    assertEquals(548, bsr.bytes());
  }
 
  @Test
  public void testReadMarks() throws Exception {
    BitStream bs = new BitStream(new byte[] { 1, 2 }, 0, Byte.SIZE * 2);
 
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.