@Test
  public void testRead1SPP64BPS() throws IOException {
    // 1 sample per pixel, 64 bits per sample (gray)
    FastByteArrayOutputStream out = new FastByteArrayOutputStream(32);
    DataOutput dataOut = new DataOutputStream(out);
    dataOut.writeLong(0x00000000);
    dataOut.writeLong(81985529216486895L);
    dataOut.writeLong(81985529216486895L);
    dataOut.writeLong(-163971058432973790L);

    InputStream in =
        new HorizontalDeDifferencingStream(out.createInputStream(), 4, 1, 64, ByteOrder.BIG_ENDIAN);
    DataInput dataIn = new DataInputStream(in);

    // Row 1
    assertEquals(0, dataIn.readLong());
    assertEquals(81985529216486895L, dataIn.readLong());
    assertEquals(163971058432973790L, dataIn.readLong());
    assertEquals(0, dataIn.readLong());

    // EOF
    assertEquals(-1, in.read());
  }
  @Test
  public void testRead1SPP32BPS() throws IOException {
    // 1 sample per pixel, 32 bits per sample (gray)
    FastByteArrayOutputStream out = new FastByteArrayOutputStream(16);
    DataOutput dataOut = new DataOutputStream(out);
    dataOut.writeInt(0x00000000);
    dataOut.writeInt(305419896);
    dataOut.writeInt(305419896);
    dataOut.writeInt(-610839792);

    InputStream in =
        new HorizontalDeDifferencingStream(out.createInputStream(), 4, 1, 32, ByteOrder.BIG_ENDIAN);
    DataInput dataIn = new DataInputStream(in);

    // Row 1
    assertEquals(0, dataIn.readInt());
    assertEquals(305419896, dataIn.readInt());
    assertEquals(610839792, dataIn.readInt());
    assertEquals(0, dataIn.readInt());

    // EOF
    assertEquals(-1, in.read());
  }
  @Test
  public void testRead3SPP16BPSLittleEndian() throws IOException {
    FastByteArrayOutputStream out = new FastByteArrayOutputStream(24);
    DataOutput dataOut = new LittleEndianDataOutputStream(out);
    dataOut.writeShort(0x0000);
    dataOut.writeShort(0x0000);
    dataOut.writeShort(0x0000);
    dataOut.writeShort(4660);
    dataOut.writeShort(30292);
    dataOut.writeShort(4660);
    dataOut.writeShort(4660);
    dataOut.writeShort(30292);
    dataOut.writeShort(4660);
    dataOut.writeShort(-9320);
    dataOut.writeShort(-60584);
    dataOut.writeShort(-9320);

    dataOut.writeShort(0x0000);
    dataOut.writeShort(0x0000);
    dataOut.writeShort(0x0000);
    dataOut.writeShort(30292);
    dataOut.writeShort(30292);
    dataOut.writeShort(30292);
    dataOut.writeShort(30292);
    dataOut.writeShort(30292);
    dataOut.writeShort(30292);
    dataOut.writeShort(-60584);
    dataOut.writeShort(-60584);
    dataOut.writeShort(-60584);

    InputStream in =
        new HorizontalDeDifferencingStream(
            out.createInputStream(), 4, 3, 16, ByteOrder.LITTLE_ENDIAN);
    DataInput dataIn = new LittleEndianDataInputStream(in);

    // Row 1
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(4660, dataIn.readUnsignedShort());
    assertEquals(30292, dataIn.readUnsignedShort());
    assertEquals(4660, dataIn.readUnsignedShort());
    assertEquals(9320, dataIn.readUnsignedShort());
    assertEquals(60584, dataIn.readUnsignedShort());
    assertEquals(9320, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());

    // Row 2
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(30292, dataIn.readUnsignedShort());
    assertEquals(30292, dataIn.readUnsignedShort());
    assertEquals(30292, dataIn.readUnsignedShort());
    assertEquals(60584, dataIn.readUnsignedShort());
    assertEquals(60584, dataIn.readUnsignedShort());
    assertEquals(60584, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());
    assertEquals(0, dataIn.readUnsignedShort());

    // EOF
    assertEquals(-1, in.read());
  }