tests/libjava-mauve/src/gnu/testlet/java/io/ByteArrayInputStream/ProtectedVars.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 /*************************************************************************
       
     2 /* ProtectedVars.java -- Test ByteArrayInputStream protected variables.
       
     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.ByteArrayInputStream;
       
    25 
       
    26 import gnu.testlet.Testlet;
       
    27 import gnu.testlet.TestHarness;
       
    28 import java.io.*;
       
    29 
       
    30 public class ProtectedVars extends ByteArrayInputStream
       
    31        implements Testlet
       
    32 {
       
    33 
       
    34 public
       
    35 ProtectedVars(byte[] b)
       
    36 {
       
    37   super(b);
       
    38 }
       
    39 
       
    40 // Constructor for the test suite
       
    41 public
       
    42 ProtectedVars()
       
    43 {
       
    44   super(new byte[1]);
       
    45 }
       
    46 
       
    47 public void
       
    48 test(TestHarness harness)
       
    49 {
       
    50   String str = "My sophomore year of college I moved out of the dorms. I\n" +
       
    51      "moved in with three friends into a brand new townhouse in east\n" +
       
    52      "Bloomington at 771 Woodbridge Drive.  To this day that was the\n" +
       
    53      "nicest place I've ever lived.\n";
       
    54 
       
    55   byte[] str_bytes = str.getBytes();  
       
    56 
       
    57   ProtectedVars bais = new ProtectedVars(str_bytes);
       
    58   byte[] read_buf = new byte[12];
       
    59 
       
    60   try 
       
    61     {
       
    62       bais.read(read_buf);
       
    63       bais.mark(0);
       
    64     
       
    65       harness.check(bais.mark, read_buf.length, "mark");
       
    66     
       
    67       bais.read(read_buf);
       
    68       harness.check(bais.pos, (read_buf.length * 2), "pos");
       
    69       harness.check(bais.count, str_bytes.length, "count");
       
    70       harness.check(bais.buf, str_bytes, "buf");
       
    71     }
       
    72   catch (IOException e)
       
    73     {
       
    74       harness.debug(e);
       
    75       harness.check(false);
       
    76     }
       
    77 }
       
    78 
       
    79 } // ProtectedVars
       
    80