GNU header update.
[cacao.git] / tests / kaffe / ReaderTest.java
1 // ReaderMarkTest.java
2 // submitted by Dalibor Topic <dtopic@socs.uts.edu.au>
3
4 import java.io.*;
5
6 public class ReaderTest {
7         public static void main(String [] args) {
8                 Reader pr = new Reader() {
9                         private int counter = 0;
10                         public void close() throws IOException {
11                         }
12                         public int read(char buf[], int offset, int count)
13                                         throws IOException {
14                                 if ((counter += count) >= 10000)
15                                         throw new IOException("enough");
16                                 return count;
17                         }
18                 };
19                 // test mark()
20                 try {
21                         pr.mark(0);
22                 } catch (IOException e) {
23                         System.out.println(e.toString());
24                 }
25                 // test reset()
26                 try {
27                         pr.reset();
28                 }
29                 catch (IOException e) {
30                         System.out.println(e.toString());
31                 }
32                 // test ready()
33                 try {
34                         System.out.println(pr.ready());
35                 } catch (IOException e) {
36                         System.out.println(e.toString());
37                 }
38                 // test skip()
39                 try {
40                         System.out.println(pr.skip(10000));
41                 } catch (IOException e) {
42                         System.out.println(e.toString());
43                 }
44         }
45 }
46
47 /* Expected Output:
48 java.io.IOException: mark() not supported
49 java.io.IOException: reset() not supported
50 false
51 java.io.IOException: enough
52 */