tests/libjava-mauve/src/gnu/testlet/java/io/BufferedInputStream/ZeroRead.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 /*************************************************************************
       
     2 /* ZeroRead.java -- BufferedInputStream zero read test
       
     3 /*
       
     4 /* Copyright (c) 2004 Free Software Foundation, Inc.
       
     5 /* Written by Jeroen Frijters (jeroen@frijters.net)
       
     6 /*
       
     7 /* This program is free software; you can redistribute it and/or modify
       
     8 /* it under the terms of the GNU General Public License as published 
       
     9 /* by the Free Software Foundation, either version 2 of the License, or
       
    10 /* (at your option) any later version.
       
    11 /*
       
    12 /* This program is distributed in the hope that it will be useful, but
       
    13 /* WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15 /* GNU General Public License for more details.
       
    16 /*
       
    17 /* You should have received a copy of the GNU General Public License
       
    18 /* along with this program; if not, write to the Free Software Foundation
       
    19 /* Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
       
    20 /*************************************************************************/
       
    21 
       
    22 // Tags: JDK1.0
       
    23 
       
    24 package gnu.testlet.java.io.BufferedInputStream;
       
    25 
       
    26 import gnu.testlet.Testlet;
       
    27 import gnu.testlet.TestHarness;
       
    28 import java.io.*;
       
    29 
       
    30 public class ZeroRead extends InputStream implements Testlet
       
    31 {
       
    32     public int read() throws IOException
       
    33     {
       
    34 	throw new IOException();
       
    35     }
       
    36 
       
    37     public int read(byte[] b, int off, int len) throws IOException
       
    38     {
       
    39 	if (len == 0)
       
    40 	    return 0;
       
    41 	throw new IOException();
       
    42     }
       
    43 
       
    44     public void test(TestHarness harness)
       
    45     {
       
    46         try
       
    47           {
       
    48 	    // Make sure that a zero length read doesn't result in a read on the
       
    49 	    // underlying stream.
       
    50 	    BufferedInputStream bis = new BufferedInputStream(this);
       
    51             harness.check(bis.read(new byte[0], 0, 0) == 0);
       
    52 	  }
       
    53         catch (IOException e)
       
    54           {
       
    55 	    harness.debug(e);
       
    56 	    harness.check(false);
       
    57 	  }
       
    58     }
       
    59 }