@Test
 public void testReadBoolean() throws IOException {
   LittleEndianDataInputStream data =
       new LittleEndianDataInputStream(
           new ByteArrayInputStream(new byte[] {0, 1, 0x7f, (byte) 0xff}));
   assertFalse(data.readBoolean());
   assertTrue(data.readBoolean());
   assertTrue(data.readBoolean());
   assertTrue(data.readBoolean());
 }
  @Test
  public void testReadByte() throws IOException {
    LittleEndianDataInputStream data =
        new LittleEndianDataInputStream(
            new ByteArrayInputStream(
                new byte[] {
                  (byte) 0x00, (byte) 0x00,
                  (byte) 0x01, (byte) 0x00,
                  (byte) 0xff, (byte) 0xff,
                  (byte) 0x00, (byte) 0x80,
                  (byte) 0xff, (byte) 0x7f,
                  (byte) 0x00, (byte) 0x01,
                }));

    assertEquals(0, data.readByte());
    assertEquals(0, data.readByte());
    assertEquals(1, data.readByte());
    assertEquals(0, data.readByte());
    assertEquals(-1, data.readByte());
    assertEquals(-1, data.readByte());
    assertEquals(0, data.readByte());
    assertEquals(Byte.MIN_VALUE, data.readByte());
    assertEquals(-1, data.readByte());
    assertEquals(Byte.MAX_VALUE, data.readByte());
    assertEquals(0, data.readByte());
    assertEquals(1, data.readByte());
  }
  @Test
  public void testReadInt() throws IOException {
    LittleEndianDataInputStream data =
        new LittleEndianDataInputStream(
            new ByteArrayInputStream(
                new byte[] {
                  (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                  (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                  (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                  (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x80,
                  (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x7f,
                  (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
                  (byte) 0xff, (byte) 0x00, (byte) 0xff, (byte) 0x00,
                  (byte) 0x00, (byte) 0xff, (byte) 0x00, (byte) 0xff,
                  (byte) 0xbe, (byte) 0xba, (byte) 0xfe, (byte) 0xca,
                  (byte) 0xca, (byte) 0xfe, (byte) 0xd0, (byte) 0x0d,
                }));

    assertEquals(0, data.readInt());
    assertEquals(1, data.readInt());
    assertEquals(-1, data.readInt());
    assertEquals(Integer.MIN_VALUE, data.readInt());
    assertEquals(Integer.MAX_VALUE, data.readInt());
    assertEquals(16777216, data.readInt());
    assertEquals(0xff00ff, data.readInt());
    assertEquals(0xff00ff00, data.readInt());
    assertEquals(0xCafeBabe, data.readInt());
    assertEquals(0x0dd0feca, data.readInt());
  }
  @Test
  public void testReadLong() throws IOException {
    LittleEndianDataInputStream data =
        new LittleEndianDataInputStream(
            new ByteArrayInputStream(
                new byte[] {
                  (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                      (byte) 0x00, (byte) 0x00,
                  (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                      (byte) 0x00, (byte) 0x00,
                  (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                      (byte) 0xff, (byte) 0xff,
                  (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                      (byte) 0x00, (byte) 0x80,
                  (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                      (byte) 0xff, (byte) 0x7f,
                  (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                      (byte) 0x00, (byte) 0x01,
                  (byte) 0x0d, (byte) 0xd0, (byte) 0xfe, (byte) 0xca, (byte) 0xbe, (byte) 0xba,
                      (byte) 0xfe, (byte) 0xca,
                }));

    assertEquals(0, data.readLong());
    assertEquals(1, data.readLong());
    assertEquals(-1, data.readLong());
    assertEquals(Long.MIN_VALUE, data.readLong());
    assertEquals(Long.MAX_VALUE, data.readLong());
    assertEquals(72057594037927936L, data.readLong());
    assertEquals(0xCafeBabeL << 32 | 0xCafeD00dL, data.readLong());
  }
  @Test
  public void testReadUnsignedShort() throws IOException {
    LittleEndianDataInputStream data =
        new LittleEndianDataInputStream(
            new ByteArrayInputStream(
                new byte[] {
                  (byte) 0x00, (byte) 0x00,
                  (byte) 0x01, (byte) 0x00,
                  (byte) 0xff, (byte) 0xff,
                  (byte) 0x00, (byte) 0x80,
                  (byte) 0xff, (byte) 0x7f,
                  (byte) 0x00, (byte) 0x01,
                }));

    assertEquals(0, data.readUnsignedShort());
    assertEquals(1, data.readUnsignedShort());
    assertEquals(Short.MAX_VALUE * 2 + 1, data.readUnsignedShort());
    assertEquals(Short.MAX_VALUE + 1, data.readUnsignedShort());
    assertEquals(Short.MAX_VALUE, data.readUnsignedShort());
    assertEquals(256, data.readUnsignedShort());
  }