Package com.peterhi.obsolete

Examples of com.peterhi.obsolete.Stream


  }
 
  @Test
  public void fReadFully_byteArray() throws Exception {
    try {
      Stream stream = new Stream();
      stream.readFully(null);
      fail();
    } catch (NullPointerException ex) {
    }
   
    try {
      Stream stream = new Stream();
      stream.readFully(new byte[1]);
      fail();
    } catch (EOFException ex) {
    }
   
    try {
      Stream stream = new Stream();
      stream.writeBit(1);
      stream.readFully(new byte[1]);
      fail();
    } catch (InsufficientBufferException ex) {
    }
  }
View Full Code Here


  }
 
  @Test
  public void fReadFully_byteArray_int_int() throws Exception {
    try {
      Stream stream = new Stream();
      stream.readFully(null, 0, 0);
      fail();
    } catch (NullPointerException ex) {
    } finally {
    }
   
    try {
      Stream stream = new Stream();
      stream.readFully(new byte[0], -1, 0);
      fail();
    } catch (IllegalArgumentException ex) {
    } finally {
    }
   
    try {
      Stream stream = new Stream();
      stream.readFully(new byte[0], 0, -1);
      fail();
    } catch (IllegalArgumentException ex) {
    } finally {
    }
   
    try {
      Stream stream = new Stream();
      stream.readFully(new byte[1], 1, 1);
      fail();
    } catch (IndexOutOfBoundsException ex) {
    } finally {
    }
   
    try {
      Stream stream = new Stream();
      stream.write(1);
      stream.readFully(new byte[2], 0, 2);
      fail();
    } catch (InsufficientBufferException ex) {
    } finally {
    }
   
    try {
      Stream stream = new Stream();
      stream.writeInt(0, 3);
      stream.readFully(new byte[1], 0, 1);
      fail();
    } catch (InsufficientBufferException ex) {
    } finally {
    }
  }
View Full Code Here

  }
 
  @Test
  public void pReadFully_byteArray_int_int() throws Exception {
    try {
      Stream stream = new Stream(sampleBytes());
      byte[] sample = new byte[0];
     
      stream.readFully(sample, 0, sample.length);
      assertEquals(sampleBytes().length, stream.available());
     
      sample = new byte[50];
      stream.readFully(sample, 25, 0);
      assertEquals(sampleBytes().length, stream.available());
     
      sample = new byte[10];
      stream.readFully(sample, 1, 2);
     
      for (int i = 0; i < 2; i++) {
        assertEquals(sampleBytes()[i], sample[i + 1]);
      }
     
      stream.readFully(sample, 2, 7);
     
      for (int i = 0; i < 7; i++) {
        assertEquals(sampleBytes()[i + 2], sample[i + 2]);
      }
     
      assertEquals(0, stream.available());
      sample = new byte[1];
      stream.readFully(sample, 1, 0);
      assertEquals(0, stream.available());
    } finally {
    }
  }
View Full Code Here

  }
 
  @Test
  public void pSkipBytes_int() throws Exception {
    try {
      Stream stream = new Stream(sampleBytes());
      stream.writeBit(1);
      assertEquals(0, stream.skipBytes(0));
      assertEquals(1, stream.skipBytes(1));
      assertEquals(sampleBytes()[1], (byte )stream.read());
      assertEquals(7, stream.skipBytes(10));
      assertEquals(0, stream.skipBytes(0));
      assertEquals(1, stream.getData().readable());
      stream.readBit();
      assertEquals(-1, stream.skipBytes(5));
    } finally {
    }
  }
View Full Code Here

  }
 
  @Test
  public void fSkipBytes_int() throws Exception {
    try {
      Stream stream = new Stream(sampleBytes());
      stream.skip(-1);
      fail();
    } catch (IllegalArgumentException ex) {
    } finally {
    }
  }
View Full Code Here

  }
 
  @Test
  public void pReadBoolean_void() throws Exception {
    try {
      Stream stream = new Stream();
      stream.writeBit(1);
      stream.write(1);
      stream.write(0);
      stream.writeBit(1);

      stream.readBit();
      assertEquals(true, stream.readBoolean());
      assertEquals(false, stream.readBoolean());
      assertEquals(1, stream.getData().readable());
    } finally {
    }
  }
View Full Code Here

  }
 
  @Test
  public void fReadBoolean_void() throws Exception {
    try {
      Stream stream = new Stream();
      stream.readBoolean();
      fail();
    } catch (EOFException ex) {
    }
   
    try {
      Stream stream = new Stream();
      stream.writeBit(1);
      stream.readBoolean();
      fail();
    } catch (InsufficientBufferException ex) {
    }
  }
View Full Code Here

TOP

Related Classes of com.peterhi.obsolete.Stream

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.