1 /************************************************************************* |
|
2 /* ProtectedVars.java -- Test CharArrayReaders 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.1 |
|
23 |
|
24 package gnu.testlet.java.io.CharArrayReader; |
|
25 |
|
26 import gnu.testlet.Testlet; |
|
27 import gnu.testlet.TestHarness; |
|
28 import java.io.*; |
|
29 |
|
30 public class ProtectedVars extends CharArrayReader implements Testlet |
|
31 { |
|
32 |
|
33 public |
|
34 ProtectedVars(char[] b) |
|
35 { |
|
36 super(b); |
|
37 } |
|
38 |
|
39 // Constructor for the test suite |
|
40 public |
|
41 ProtectedVars() |
|
42 { |
|
43 super(new char[1]); |
|
44 } |
|
45 |
|
46 public void |
|
47 test(TestHarness harness) |
|
48 { |
|
49 String str = "In junior high, I did a lot writing. I wrote a science\n" + |
|
50 "fiction novel length story that was called 'The Destruction of\n" + |
|
51 "Planet Earth'. All the characters in the story were my friends \n" + |
|
52 "from school because I couldn't think up any cool names."; |
|
53 |
|
54 char[] str_chars = new char[str.length()]; |
|
55 str.getChars(0, str.length(), str_chars, 0); |
|
56 |
|
57 ProtectedVars car = new ProtectedVars(str_chars); |
|
58 char[] read_buf = new char[12]; |
|
59 |
|
60 try |
|
61 { |
|
62 car.read(read_buf); |
|
63 car.mark(0); |
|
64 |
|
65 harness.check(car.markedPos, read_buf.length, "markedPos"); |
|
66 |
|
67 car.read(read_buf); |
|
68 harness.check(car.pos, (read_buf.length * 2), "pos"); |
|
69 harness.check(car.count, str_chars.length, "count"); |
|
70 harness.check(car.buf, str_chars, "buf"); |
|
71 } |
|
72 catch (IOException e) |
|
73 { |
|
74 harness.debug(e); |
|
75 harness.check(false); |
|
76 } |
|
77 } |
|
78 |
|
79 } // ProtectedVars |
|
80 |
|