Package com.peterhi.runtime

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


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

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

      assertEquals(2, bs.bytes());
    }
   
    {
      BitStream bs = new BitStream(32);
      assertEquals(0, bs.available());
      assertEquals(32, bs.bytes());
      assertEquals(-1, bs.readBit());
    }
  }
 
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());
    }
  }
 
View Full Code Here

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

        if (size == Byte.SIZE || size == Short.SIZE || size == Integer.SIZE || size == Long.SIZE) {
          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));
     
View Full Code Here

      Integer size = entry.getValue();
      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);
   
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 {
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.