Пример #1
0
 @Test
 public void doubleAsBytes() throws Exception {
   double[] array1 = new double[] {1.0, 2.0, 3.0, 4.0, 5.0};
   Bits bits = Bits.bits(array1.length * 8);
   for (double value : array1) {
     bits.put(Double.doubleToRawLongBits(value));
   }
   String first = bits.toString();
   byte[] asBytes = bits.asBytes();
   String other = Bits.bitsFromBytes(asBytes).toString();
   assertEquals(first, other);
 }
Пример #2
0
  @Test
  public void asBytes() throws Exception {
    int numberOfBytes = 14;
    Bits bits = bits(numberOfBytes);
    for (byte i = 0; i < numberOfBytes; i++) {
      bits.put(i);
    }

    byte[] bytes = bits.asBytes();
    for (byte i = 0; i < numberOfBytes; i++) {
      assertEquals(i, bytes[i]);
    }
  }