예제 #1
0
  /** test the putLong method */
  public void testPutLong() {
    // writing 8 byte values to a 9 byte buffer
    byte[] expected = {
      (byte) 0x01,
      (byte) 0xFF,
      (byte) 0xFF,
      (byte) 0xFF,
      (byte) 0xFF,
      (byte) 0xFF,
      (byte) 0xFF,
      (byte) 0xFF,
      (byte) 0x02,
    };
    byte[] received = new byte[LittleEndian.LONG_SIZE + 1];

    long testdata0 = 0xFFFFFFFFFFFFFF01L;
    long testdata1 = 0x02FFFFFFFFFFFFFFL;
    LittleEndian.putLong(received, 0, testdata0);
    assertTrue(compareByteArrays(received, expected, 0, LittleEndian.LONG_SIZE));
    LittleEndian.putLong(received, 1, testdata1);
    assertTrue(compareByteArrays(received, expected, 1, LittleEndian.LONG_SIZE));
  }