Package javax.imageio.stream.ImageInputStreamImplTest

Examples of javax.imageio.stream.ImageInputStreamImplTest.BasicImageInputStreamImpl


  public void testWriteShorts() throws IOException {
    final short[] src = new short[] { 1, 2, 3 };
    final short[] dest = new short[3];
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(
        2 * dest.length);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeShorts(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeShorts(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));
  }
View Full Code Here


  public void testWriteInts() throws IOException {
    final int[] src = new int[] { 1, 2, 3 };
    final int[] dest = new int[3];
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(
        4 * dest.length);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeInts(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeInts(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));
  }
View Full Code Here

  public void testWriteLongs() throws IOException {
    final long[] src = new long[] { 1, 2, 3 };
    final long[] dest = new long[3];
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(
        8 * dest.length);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeLongs(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeLongs(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));
  }
View Full Code Here

  public void testWriteFloats() throws IOException {
    final float[] src = new float[] { 1, 2, 3 };
    final float[] dest = new float[3];
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(
        4 * dest.length);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeFloats(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeFloats(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));
  }
View Full Code Here

    assertTrue(Arrays.equals(src, dest));
  }
 
  public void testWriteBits() throws IOException {
      final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(8);
      final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);
     
      out.writeBits(0xff, 7);
      out.writeBit(0);
      out.writeBits(0xabcdef, 24);
      assertEquals("writeBits failed", 0xfe, in.read());
      assertEquals("writeBits failed", 0xab, in.read());
      assertEquals("writeBits failed", 0xcd, in.read());
      assertEquals("writeBits failed", 0xef, in.read());
  }
View Full Code Here

  public void _testWriteDoubles() throws IOException {
    final double[] src = new double[] { 1, 2, 3 };
    final double[] dest = new double[3];
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(
        8 * dest.length);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeDoubles(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeDoubles(src, 0, 3);
    in.readFully(dest, 0, 3);
    assertTrue(Arrays.equals(src, dest));
  }
View Full Code Here

  }

  public void testWriteUTF() throws IOException {
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(
        100);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeUTF("test");
    assertEquals("test", in.readUTF());

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeUTF("test");
    assertEquals("test", in.readUTF());
  }
View Full Code Here

    assertEquals(Short.MAX_VALUE, in.readShort());
  }

  public void testWriteInt() throws IOException {
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(4);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeInt(Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, in.readInt());

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeInt(Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, in.readInt());
  }
View Full Code Here

    assertEquals(Integer.MAX_VALUE, in.readInt());
  }

  public void testWriteLong() throws IOException {
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(8);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeLong(Long.MAX_VALUE);
    assertEquals(Long.MAX_VALUE, in.readLong());

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeLong(Long.MAX_VALUE);
    assertEquals(Long.MAX_VALUE, in.readLong());
  }
View Full Code Here

  public void testWriteChars() throws IOException {
    final char[] buff = new char[4];
    final BasicImageOutputStreamImpl out = new BasicImageOutputStreamImpl(
        2 * buff.length);
    final ImageInputStream in = new BasicImageInputStreamImpl(out.buff);

    out.writeChars("test");
    in.readFully(buff, 0, 4);
    assertEquals("test", new String(buff));

    out.reset();
    in.reset();
    out.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
    out.writeChars("test");
    in.readFully(buff, 0, 4);
    assertEquals("test", new String(buff));

    out.reset();
    in.reset();
    out.writeChars(" test".toCharArray(), 1, 4);
    in.readFully(buff, 0, 4);
    assertEquals("test", new String(buff));
  }
View Full Code Here

TOP

Related Classes of javax.imageio.stream.ImageInputStreamImplTest.BasicImageInputStreamImpl

Copyright © 2018 www.massapicom. 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.