tests/libjava-mauve/src/gnu/testlet/java/io/StringBufferInputStream/MarkReset.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 /*************************************************************************
       
     2 /* MarkReset.java -- StringBufferInputStream mark/reset test
       
     3 /*
       
     4 /* Copyright (c) 1998 Free Software Foundation, Inc.
       
     5 /* Written by Aaron M. Renn (arenn@urbanophile.com)
       
     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.StringBufferInputStream;
       
    25 
       
    26 import gnu.testlet.Testlet;
       
    27 import gnu.testlet.TestHarness;
       
    28 import java.io.*;
       
    29 
       
    30 public class MarkReset implements Testlet
       
    31 {
       
    32 
       
    33 public void
       
    34 test(TestHarness harness)
       
    35 {
       
    36   String str = "Between my freshman and sophomore years of high school\n" +
       
    37     "we moved into a brand new building.  The old high school was turned\n" +
       
    38     "into an elementary school.\n";
       
    39 
       
    40   StringBufferInputStream sbis = new StringBufferInputStream(str);
       
    41 
       
    42   try
       
    43     {
       
    44       boolean passed = true;
       
    45 
       
    46       byte[] read_buf = new byte[12];
       
    47       sbis.read(read_buf);      
       
    48       harness.check(sbis.available(), str.length() - read_buf.length, 
       
    49                     "available pre skip");
       
    50       harness.check(sbis.skip(5), 5, "skip");
       
    51       harness.check(sbis.available(), str.length() - (read_buf.length + 5), 
       
    52                     "available post skip");
       
    53       harness.check(!sbis.markSupported(), "markSupported");
       
    54       sbis.reset();
       
    55       harness.check(sbis.available(), str.length(), "reset()"); 
       
    56     }
       
    57   catch(IOException e)
       
    58     {
       
    59       harness.debug(e);
       
    60       harness.check(false);
       
    61     }
       
    62 }
       
    63 
       
    64 }
       
    65