### Question:
NoClosePipedInputStream extends InputStream { public synchronized int available() throws IOException { if(in < 0) return 0; else if(in == out) return buffer.length; else if (in > out) return in - out; else return in + buffer.length - out; } NoClosePipedInputStream(NoClosePipedOutputStream src);  NoClosePipedInputStream(NoClosePipedOutputStream src, int pipeSize);  NoClosePipedInputStream();  NoClosePipedInputStream(int pipeSize); void connect(NoClosePipedOutputStream src); synchronized int read(); synchronized int read(byte b[], int off, int len); synchronized int available();  }### Answer:
@Test public void testNegativeInAvailable() throws IOException { in.in = -1; assertEquals(0, in.available()); }
@Test public void testInEqualsOutAvailable() throws IOException { in.in=1; in.out=1; assertEquals(in.buffer.length, in.available()); }
@Test public void testInGreaterThanOutAvailable() throws IOException { in.in = 3; in.out = 1; assertEquals(in.in - in.out, in.available()); }
@Test public void testNormalAvailable() throws IOException { in.in = 1; in.out = 3; assertEquals(in.in + in.buffer.length - in.out, in.available()); }