summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron M. Renn <arenn@urbanophile.com>1998-06-19 23:02:21 +0000
committerAaron M. Renn <arenn@urbanophile.com>1998-06-19 23:02:21 +0000
commit56777510510cc5b31a59af7af582c91a94f122f2 (patch)
tree884d91b5e870d7f5f217b617207ca67bd306e406 /test
parent0c416615543e7df9c122a410c626f2baa0077375 (diff)
downloadclasspath-56777510510cc5b31a59af7af582c91a94f122f2.tar.gz
Initial Checkin
Diffstat (limited to 'test')
-rw-r--r--test/java.io/BufferedInputStreamTest.java239
-rw-r--r--test/java.io/ByteArrayInputStreamTest.java172
-rw-r--r--test/java.io/ChangeLog36
-rw-r--r--test/java.io/DataInputOutputTest.java164
-rw-r--r--test/java.io/LineNumberInputStreamTest.java117
-rw-r--r--test/java.io/Makefile.am9
-rw-r--r--test/java.io/PushbackInputStreamTest.java131
-rw-r--r--test/java.io/SequenceInputStreamTest.java83
-rw-r--r--test/java.io/StringBufferInputStreamTest.java161
-rw-r--r--test/java.io/dataoutput-jdk.outbin0 -> 113 bytes
10 files changed, 1112 insertions, 0 deletions
diff --git a/test/java.io/BufferedInputStreamTest.java b/test/java.io/BufferedInputStreamTest.java
new file mode 100644
index 000000000..5599ecae0
--- /dev/null
+++ b/test/java.io/BufferedInputStreamTest.java
@@ -0,0 +1,239 @@
+/*************************************************************************
+/* BufferedInputStreamTest.java -- Tests BufferedInputStream's
+/*
+/* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU General Public License as published
+/* by the Free Software Foundation, version 2. (see COPYING)
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/* GNU General Public License for more details.
+/*
+/* You should have received a copy of the GNU General Public License
+/* along with this program; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+import java.io.*;
+
+public class BufferedInputStreamTest extends BufferedInputStream
+{
+
+public
+BufferedInputStreamTest(InputStream in, int size)
+{
+ super(in, size);
+}
+
+public static int
+marktest(InputStream ins) throws IOException
+{
+ BufferedInputStream bis = new BufferedInputStream(ins, 15);
+
+ int bytes_read;
+ int total_read = 0;
+ byte[] buf = new byte[12];
+
+ bytes_read = bis.read(buf);
+ total_read += bytes_read;
+ System.out.print(new String(buf, 0, bytes_read));
+
+ bytes_read = bis.read(buf);
+ total_read += bytes_read;
+ System.out.print(new String(buf, 0, bytes_read));
+
+ bis.mark(75);
+ bis.read();
+ bis.read(buf);
+ bis.read(buf);
+ bis.read(buf);
+ bis.reset();
+
+ bytes_read = bis.read(buf);
+ total_read += bytes_read;
+ System.out.print(new String(buf, 0, bytes_read));
+
+ bis.mark(555);
+
+ bytes_read = bis.read(buf);
+ total_read += bytes_read;
+ System.out.print(new String(buf, 0, bytes_read));
+
+ bis.reset();
+
+ bis.read(buf);
+ bytes_read = bis.read(buf);
+ total_read += bytes_read;
+ System.out.print(new String(buf, 0, bytes_read));
+
+ bytes_read = bis.read(buf);
+ total_read += bytes_read;
+ System.out.print(new String(buf, 0, bytes_read));
+
+ bis.mark(14);
+
+ bis.read(buf);
+
+ bis.reset();
+
+ bytes_read = bis.read(buf);
+ total_read += bytes_read;
+ System.out.print(new String(buf, 0, bytes_read));
+
+ while ((bytes_read = bis.read(buf)) != -1)
+ {
+ System.out.print(new String(buf, 0, bytes_read));
+ total_read += bytes_read;
+ }
+
+ return(total_read);
+}
+
+public static void
+main(String[] argv)
+{
+ System.out.println("Started test of BufferedInputStream");
+
+ try
+ {
+ System.out.println("Test 1: Protected Variables Test");
+
+ String str = "This is a test line of text for this pass";
+
+ StringBufferInputStream sbis = new StringBufferInputStream(str);
+ BufferedInputStreamTest bist = new BufferedInputStreamTest(sbis, 12);
+
+ bist.read();
+ bist.mark(5);
+
+ boolean passed = true;
+
+ if (bist.buf.length != 12)
+ {
+ passed = false;
+ System.out.println("buf.length is wrong. Expected 12, but got " +
+ bist.buf.length);
+ }
+ if (bist.count != 12)
+ {
+ passed = false;
+ System.out.println("count is wrong. Expected 12, but got " +
+ bist.count);
+ }
+ if (bist.marklimit != 5)
+ {
+ passed = false;
+ System.out.println("marklimit is wrong. Expected 5, but got " +
+ bist.marklimit);
+ }
+ if (bist.markpos != 1)
+ {
+ passed = false;
+ System.out.println("markpos is wrong. Expected 5, but got " +
+ bist.markpos);
+ }
+ if (bist.pos != 1)
+ {
+ passed = false;
+ System.out.println("pos is wrong. Expected 1, but got " +
+ bist.pos);
+ }
+
+ if (passed)
+ System.out.println("PASSED: Protected Variables Test");
+ else
+ System.out.println("FAILED: Protected Variables Test");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: Protected Variables Test: " + e);
+ }
+
+ try
+ {
+ System.out.println("Test 2: Simple Read Test");
+
+ String str = "One of my 8th grade teachers was Mr. Russell.\n" +
+ "He used to start each year off by telling the class that the\n" +
+ "earth was flat. He did it to teach people to question\n" +
+ "things they are told. But everybody knew that he did it\n" +
+ "so it lost its effect.\n";
+
+ StringBufferInputStream sbis = new StringBufferInputStream(str);
+ BufferedInputStream bis = new BufferedInputStream(sbis, 15);
+
+ byte[] buf = new byte[12];
+ int bytes_read;
+ while((bytes_read = bis.read(buf)) != -1)
+ System.out.print(new String(buf, 0, bytes_read));
+
+ bis.close();
+ System.out.println("PASSED: Simple Read Test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: Simple Read Test: " + e);
+ }
+
+ try
+ {
+ System.out.println("Test 3: First mark/reset Test");
+
+ String str = "My 6th grade teacher was named Mrs. Hostetler.\n" +
+ "She had a whole list of rules that you were supposed to follow\n" +
+ "in class and if you broke a rule she would make you write the\n" +
+ "rules out several times. The number varied depending on what\n" +
+ "rule you broke. Since I knew I would get in trouble, I would\n" +
+ "just go ahead and write out a few sets on the long school bus\n" +
+ "ride home so that if had to stay in during recess and write\n" +
+ "rules, five minutes later I could just tell the teacher I was\n" +
+ "done so I could go outside and play kickball.\n";
+
+ StringBufferInputStream sbis = new StringBufferInputStream(str);
+
+ int total_read = marktest(sbis);
+
+ if (total_read == str.length())
+ System.out.println("PASSED: First mark/reset Test");
+ else
+ System.out.println("FAILED: First mark/reset Test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: First mark/reset Test: " + e);
+ }
+
+ try
+ {
+ System.out.println("Test 4: Second mark/reset Test");
+
+ String str = "My first day of college was fun. A bunch of us\n" +
+ "got pretty drunk, then this guy named Rick Flake (I'm not\n" +
+ "making that name up) took a piss in the bed of a Physical\n" +
+ "Plant dept pickup truck. Later on we were walking across\n" +
+ "campus, saw a cop, and took off running for no reason.\n" +
+ "When we got back to the dorm we found an even drunker guy\n" +
+ "passed out in a shopping cart outside.\n";
+
+ ByteArrayInputStream sbis = new ByteArrayInputStream(str.getBytes());
+
+ int total_read = marktest(sbis);
+
+ if (total_read == str.length())
+ System.out.println("PASSED: Second mark/reset Test");
+ else
+ System.out.println("FAILED: Second mark/reset Test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: Second mark/reset Test: " + e);
+ }
+
+ System.out.println("Finished test of BufferedInputStream");
+} // main
+
+} // class BufferedInputStreamTest
+
diff --git a/test/java.io/ByteArrayInputStreamTest.java b/test/java.io/ByteArrayInputStreamTest.java
new file mode 100644
index 000000000..6c5841508
--- /dev/null
+++ b/test/java.io/ByteArrayInputStreamTest.java
@@ -0,0 +1,172 @@
+/*************************************************************************
+/* ByteArrayInputStreamTest.java -- Test ByteArrayInputStream's of course
+/*
+/* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU General Public License as published
+/* by the Free Software Foundation, version 2. (see COPYING)
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/* GNU General Public License for more details.
+/*
+/* You should have received a copy of the GNU General Public License
+/* along with this program; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+import java.io.*;
+
+public class ByteArrayInputStreamTest extends ByteArrayInputStream
+{
+
+public
+ByteArrayInputStreamTest(byte[] b)
+{
+ super(b);
+}
+
+public static void
+main(String[] argv)
+{
+ System.out.println("Starting test of ByteArrayInputStream.");
+ System.out.flush();
+
+ String str = "My sophomore year of college I moved out of the dorms. I\n" +
+ "moved in with three friends into a brand new townhouse in east\n" +
+ "Bloomington at 771 Woodbridge Drive. To this day that was the\n" +
+ "nicest place I've ever lived.\n";
+
+ byte[] str_bytes = str.getBytes();
+
+ System.out.println("Test 1: Protected Variables");
+
+ ByteArrayInputStreamTest bais = new ByteArrayInputStreamTest(str_bytes);
+ byte[] read_buf = new byte[12];
+
+ try
+ {
+ bais.read(read_buf);
+ bais.mark(0);
+
+ boolean passed = true;
+
+ if (bais.mark != read_buf.length)
+ {
+ passed = false;
+ System.out.println("The mark variable is wrong. Expected " +
+ read_buf.length + " and got " + bais.mark);
+ }
+ bais.read(read_buf);
+ if (bais.pos != (read_buf.length * 2))
+ {
+ passed = false;
+ System.out.println("The pos variable is wrong. Expected 24 and got " +
+ bais.pos);
+ }
+ if (bais.count != str_bytes.length)
+ {
+ passed = false;
+ System.out.println("The count variable is wrong. Expected " +
+ str_bytes.length + " and got " + bais.pos);
+ }
+ if (bais.buf != str_bytes)
+ {
+ passed = false;
+ System.out.println("The buf variable is not correct");
+ }
+
+ if (passed)
+ System.out.println("PASSED: Protected Variables Test");
+ else
+ System.out.println("FAILED: Protected Variables Test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: Protected Variables Test: " + e);
+ }
+
+ System.out.println("Test 2: Simple Read Test");
+
+ bais = new ByteArrayInputStreamTest(str_bytes);
+
+ try
+ {
+ int bytes_read, total_read = 0;
+ while ((bytes_read = bais.read(read_buf, 0, read_buf.length)) != -1)
+ {
+ System.out.print(new String(read_buf, 0, bytes_read));
+ total_read += bytes_read;
+ }
+
+ bais.close();
+ if (total_read == str.length())
+ System.out.println("PASSED: Simple Read Test");
+ else
+ System.out.println("FAILED: Simple Read Test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: Simple Read Test: " + e);
+ }
+
+ System.out.println("Test 3: mark/reset/available/skip test");
+ bais = new ByteArrayInputStreamTest(str_bytes);
+
+ try
+ {
+ boolean passed = true;
+
+ bais.read(read_buf);
+ if (bais.available() != (str_bytes.length - read_buf.length))
+ {
+ passed = false;
+ System.out.println("available() reported " + bais.available() +
+ " and " + (str_bytes.length - read_buf.length) +
+ " was expected");
+ }
+
+ if (bais.skip(5) != 5)
+ {
+ passed = false;
+ System.out.println("skip() didn't work");
+ }
+ if (bais.available() != (str_bytes.length - (read_buf.length + 5)))
+ {
+ passed = false;
+ System.out.println("skip() lied");
+ }
+
+ if (!bais.markSupported())
+ {
+ passed = false;
+ System.out.println("markSupported() should have returned true but returned false");
+ }
+
+ bais.mark(0);
+ int availsave = bais.available();
+ bais.read();
+ bais.reset();
+ if (bais.available() != availsave)
+ {
+ passed = false;
+ System.out.println("mark/reset failed to work");
+ }
+
+ if (passed)
+ System.out.println("PASSED: mark/reset/available/skip test");
+ else
+ System.out.println("FAILED: mark/reset/available/skip test");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: mark/reset/available/skip test: " + e);
+ }
+
+ System.out.println("Finished ByteArrayInputStream test");
+}
+
+}
+
diff --git a/test/java.io/ChangeLog b/test/java.io/ChangeLog
new file mode 100644
index 000000000..e5dbab97c
--- /dev/null
+++ b/test/java.io/ChangeLog
@@ -0,0 +1,36 @@
+Tue Jun 16 20:09:50 1998 arenn's Development Account <devel@larissa.foo.com>
+
+ * DataInputOutputTest.java: Finished this class and initial debug
+ round of DataInputStream.
+
+Sun Jun 16 17:29:19 1998 arenn's Development Account <devel@larissa.foo.com>
+
+ * DataInputOutputTest.java: Wrote this class and started debugging
+ DataInputStream.
+
+Sat Jun 13 15:18:30 1998 arenn's Development Account <devel@larissa.foo.com>
+
+ * BufferedInputStreamTest.java: Wrote this class and tested
+ BufferedInputStream
+
+Fri Jun 12 19:45:22 1998 arenn's Development Account <devel@larissa.foo.com>
+
+ * LineNumberInputStreamTest.java: Wrote this class and tested
+ LineNumberInputStream.
+
+Thu Jun 11 19:57:16 1998 arenn's Development Account <devel@larissa.foo.com>
+
+ * PushbackInputStreamTest.java: Wrote this class and tested
+ PushbackInputStream.
+
+ * SequenceInputStreamTest.java: Wrote this class and test the
+ SequenceInputStream class.
+
+ * StringBufferInputStreamTest.java: Wrote this class and tested
+ the StringBufferInputStream class.
+
+Wed Jun 10 21:56:38 1998 arenn's Development Account <devel@larissa.foo.com>
+
+ * ByteArrayInputStreamTest.java: Wrote this class and started test
+ of the ByteArrayInputStream class.
+
diff --git a/test/java.io/DataInputOutputTest.java b/test/java.io/DataInputOutputTest.java
new file mode 100644
index 000000000..b17609ef3
--- /dev/null
+++ b/test/java.io/DataInputOutputTest.java
@@ -0,0 +1,164 @@
+/*************************************************************************
+/* DataInputOutputTest.java -- Tests Data{Input,Output}Stream's
+/*
+/* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU General Public License as published
+/* by the Free Software Foundation, version 2. (see COPYING)
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/* GNU General Public License for more details.
+/*
+/* You should have received a copy of the GNU General Public License
+/* along with this program; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+import java.io.*;
+
+// Write some data using DataOutput and read it using DataInput.
+
+public class DataInputOutputTest
+{
+
+public static void
+main(String[] argv)
+{
+ System.out.println("Started test of DataInputStream and DataOutputStream");
+
+ try
+ {
+ System.out.println("Test 1: DataOutputStream write test");
+
+ FileOutputStream fos = new FileOutputStream("dataoutput.out");
+ DataOutputStream dos = new DataOutputStream(fos);
+
+ dos.writeBoolean(true);
+ dos.writeBoolean(false);
+ dos.writeByte((byte)8);
+ dos.writeByte((byte)-122);
+ dos.writeChar((char)'a');
+ dos.writeChar((char)'\uE2D2');
+ dos.writeShort((short)32000);
+ dos.writeInt((int)8675309);
+ dos.writeLong((long)696969696969);
+ dos.writeFloat((float)3.1415);
+ dos.writeDouble((double)999999999.999);
+ dos.writeUTF("Testing code is such a boring activity but it must be done");
+ dos.writeUTF("a-->\u01FF\uA000\u6666\u0200RRR");
+ dos.close();
+
+ // We'll find out if this was really right later, but conditionally
+ // report success for now
+ System.out.println("PASSED: DataOutputStream write test");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: DataOutputStream write test: " + e);
+ }
+
+ try
+ {
+ System.out.println("Test 2: DataInputStream read test");
+
+ FileInputStream fis = new FileInputStream("dataoutput-jdk.out");
+ DataInputStream dis = new DataInputStream(fis);
+
+ boolean passed = true;
+
+ boolean b = dis.readBoolean();
+ if (b != true)
+ {
+ passed = false;
+ System.out.println("Failed to read boolean. Expected true and got false");
+ }
+ b = dis.readBoolean();
+ if (b != false)
+ {
+ passed = false;
+ System.out.println("Failed to read boolean. Expected false and got true");
+ }
+ byte bt = dis.readByte();
+ if (bt != 8)
+ {
+ passed = false;
+ System.out.println("Failed to read byte. Expected 8 and got "+ bt);
+ }
+ bt = dis.readByte();
+ if (bt != -122)
+ {
+ passed = false;
+ System.out.println("Failed to read byte. Expected -122 and got "+ bt);
+ }
+ char c = dis.readChar();
+ if (c != 'a')
+ {
+ passed = false;
+ System.out.println("Failed to read char. Expected a and got " + c);
+ }
+ c = dis.readChar();
+ if (c != '\uE2D2')
+ {
+ passed = false;
+ System.out.println("Failed to read char. Expected \\uE2D2 and got " + c);
+ }
+ short s = dis.readShort();
+ if (s != 32000)
+ {
+ passed = false;
+ System.out.println("Failed to read short. Expected 32000 and got " + s);
+ }
+ int i = dis.readInt();
+ if (i != 8675309)
+ {
+ passed = false;
+ System.out.println("Failed to read int. Expected 8675309 and got " + i);
+ }
+ long l = dis.readLong();
+ if (l != 696969696969)
+ {
+ passed = false;
+ System.out.println("Failed to read long. Expected 696969696969 and got " + l);
+ }
+ float f = dis.readFloat();
+ if (!Float.toString(f).equals("3.1415"))
+ {
+ passed = false;
+ System.out.println("Failed to read float. Expected 3.1415 and got " + f);
+ }
+ double d = dis.readDouble();
+ if (d != 999999999.999)
+ {
+ passed = false;
+ System.out.println("Failed to read double. Expected 999999999.999 and got " + d);
+ }
+ String str = dis.readUTF();
+ if (!str.equals("Testing code is such a boring activity but it must be done"))
+ {
+ passed = false;
+ System.out.println("Read unexpected String: " + str);
+ }
+ str = dis.readUTF();
+ if (!str.equals("a-->\u01FF\uA000\u6666\u0200RRR"))
+ {
+ passed = false;
+ System.out.println("Read unexpected String: " + str);
+ }
+
+ if (passed)
+ System.out.println("PASSED: DataInputStream read test");
+ else
+ System.out.println("FAILED: DataInputStream read test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: DataInputStream read test: " + e);
+ }
+
+} // main
+
+} // class DataInputOutputTest
+
diff --git a/test/java.io/LineNumberInputStreamTest.java b/test/java.io/LineNumberInputStreamTest.java
new file mode 100644
index 000000000..a85693679
--- /dev/null
+++ b/test/java.io/LineNumberInputStreamTest.java
@@ -0,0 +1,117 @@
+/*************************************************************************
+/* LineNumberInputStreamTest.java -- Tests LineNumberInputStream's
+/*
+/* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU General Public License as published
+/* by the Free Software Foundation, version 2. (see COPYING)
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/* GNU General Public License for more details.
+/*
+/* You should have received a copy of the GNU General Public License
+/* along with this program; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+import java.io.*;
+
+public class LineNumberInputStreamTest
+{
+
+public static void
+main(String[] argv)
+{
+ System.out.println("Started test of LineNumberInputStream");
+
+ try
+ {
+ System.out.println("Test 1: First test series");
+
+ boolean passed = true;
+
+ String str = "I grew up by a small town called Laconia, Indiana\r" +
+ "which has a population of about 64 people. But I didn't live\r\n" +
+ "in town. I lived on a gravel road about 4 miles away\n" +
+ "They paved that road\n";
+
+ StringBufferInputStream sbis = new StringBufferInputStream(str);
+ LineNumberInputStream lnis = new LineNumberInputStream(sbis);
+
+ lnis.setLineNumber(2);
+
+ byte[] buf = new byte[32];
+ int bytes_read;
+ while ((bytes_read = lnis.read(buf)) != -1)
+ {
+ str = new String(buf, 0, bytes_read);
+ if (str.indexOf("\r") != -1)
+ {
+ passed = false;
+ System.out.println("\nFound an unexpected \\r\n");
+ }
+
+ System.out.print(str);
+ }
+
+ if (lnis.getLineNumber() != 6)
+ {
+ passed = false;
+ System.out.println("Line number was wrong. Expected 6 but got " +
+ lnis.getLineNumber());
+ }
+
+ if (passed)
+ System.out.println("PASSED: First test series");
+ else
+ System.out.println("FAILED: First test series");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: First test series: " + e);
+ }
+
+ try
+ {
+ System.out.println("Test 2: Second test series");
+
+ boolean passed = true;
+
+ String str = "One time I was playing kickball on the playground\n" +
+ "in 4th grade and my friends kept talking about how they smelled\n" +
+ "pot. I kept asking them what they smelled because I couldn't\n" +
+ "figure out how a pot could have a smell";
+
+ StringBufferInputStream sbis = new StringBufferInputStream(str);
+ LineNumberInputStream lnis = new LineNumberInputStream(sbis);
+
+ byte[] buf = new byte[32];
+ int bytes_read;
+ while ((bytes_read = lnis.read(buf)) != -1)
+ System.out.print(new String(buf, 0, bytes_read));
+
+ if (lnis.getLineNumber() != 3)
+ {
+ passed = false;
+ System.out.println("\nLine number was wrong. Expected 3 but got " +
+ lnis.getLineNumber());
+ }
+
+ if (passed)
+ System.out.println("PASSED: Second test series");
+ else
+ System.out.println("FAILED: Second test series");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: Second test series: " + e);
+ }
+
+ System.out.println("Finished test of LineNumberInputStream");
+}
+
+} // class LineNumberInputStreamTest
+
diff --git a/test/java.io/Makefile.am b/test/java.io/Makefile.am
new file mode 100644
index 000000000..923e37830
--- /dev/null
+++ b/test/java.io/Makefile.am
@@ -0,0 +1,9 @@
+## Input file for automake to generate the Makefile.in used by configure
+
+JAVAROOT = .
+
+check_JAVA = BufferedInputStreamTest.java ByteArrayInputStreamTest.java \
+ DataInputOutputTest.java LineNumberInputStreamTest.java \
+ PushbackInputStreamTest.java SequenceInputStreamTest.java \
+ StringBufferInputStreamTest.java
+
diff --git a/test/java.io/PushbackInputStreamTest.java b/test/java.io/PushbackInputStreamTest.java
new file mode 100644
index 000000000..ab9e98f09
--- /dev/null
+++ b/test/java.io/PushbackInputStreamTest.java
@@ -0,0 +1,131 @@
+/*************************************************************************
+/* PushbackInputStreamTest.java -- Tests PushbackInputStream's of course
+/*
+/* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU General Public License as published
+/* by the Free Software Foundation, version 2. (see COPYING)
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/* GNU General Public License for more details.
+/*
+/* You should have received a copy of the GNU General Public License
+/* along with this program; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+import java.io.*;
+
+public class PushbackInputStreamTest extends PushbackInputStream
+{
+
+public
+PushbackInputStreamTest(InputStream is, int size)
+{
+ super(is, size);
+}
+
+public static void
+main(String[] argv)
+{
+ System.out.println("Started test of PushbackInputStream");
+
+ String str = "Once when I was in fourth grade, my friend Lloyd\n" +
+ "Saltsgaver and I got in trouble for kicking a bunch of\n" +
+ "Kindergartners off the horse swings so we could play a game\n" +
+ "of 'road hog'\n";
+
+ System.out.println("Test 1: Protected Variables Test");
+ {
+ PushbackInputStreamTest pist = new PushbackInputStreamTest(
+ new StringBufferInputStream(str), 15);
+
+ boolean passed = true;
+ if (pist.pos != pist.buf.length)
+ {
+ passed = false;
+ System.out.println("The pos variable is wrong. Expected " +
+ pist.buf.length + " but got " + pist.pos);
+ }
+ if (pist.buf.length != 15)
+ {
+ passed = false;
+ System.out.println("The buf.length is wrong. Expected 15" +
+ " but got " + pist.buf.length);
+ }
+
+ if (passed)
+ System.out.println("PASSED: Protected Variables Test");
+ else
+ System.out.println("FAILED: Protected Variables Test");
+ }
+
+ System.out.println("Test 2: Basic Unread Tests");
+ try
+ {
+ PushbackInputStreamTest pist = new PushbackInputStreamTest(
+ new StringBufferInputStream(str), 15);
+
+ byte[] read_buf1 = new byte[12];
+ byte[] read_buf2 = new byte[12];
+
+ boolean passed = true;
+
+ pist.read(read_buf1);
+ pist.unread(read_buf1);
+ pist.read(read_buf2);
+
+ for (int i = 0; i < read_buf1.length; i++)
+ {
+ if (read_buf1[i] != read_buf2[i])
+ passed = false;
+ }
+
+ pist.unread(read_buf2, 1, read_buf2.length - 1);
+ pist.unread(read_buf2[0]);
+
+ int bytes_read, total_read = 0;
+ while ((bytes_read = pist.read(read_buf1)) != -1)
+ {
+ System.out.print(new String(read_buf1, 0, bytes_read));
+ total_read += bytes_read;
+ }
+
+ if (total_read != str.length())
+ passed = false;
+
+ if (passed)
+ System.out.println("PASSED: Basic Unread Tests");
+ else
+ System.out.println("FAILED: Basic Unread Tests");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: Basic Unread Tests: " + e);
+ }
+
+ System.out.println("Test 3: Buffer Overflow Test");
+ try
+ {
+ PushbackInputStreamTest pist = new PushbackInputStreamTest(
+ new StringBufferInputStream(str), 10);
+
+ byte[] read_buf = new byte[12];
+
+ pist.read(read_buf);
+ pist.unread(read_buf);
+ System.out.println("FAILED: Buffer Overflow Test");
+ }
+ catch(IOException e)
+ {
+ System.out.println("PASSED: Buffer Overflow Test: " + e);
+ }
+
+ System.out.println("Finished tests of PushbackInputStream");
+} // main
+
+} // class PushbackInputStreamTest
+
diff --git a/test/java.io/SequenceInputStreamTest.java b/test/java.io/SequenceInputStreamTest.java
new file mode 100644
index 000000000..fa4f263b3
--- /dev/null
+++ b/test/java.io/SequenceInputStreamTest.java
@@ -0,0 +1,83 @@
+/*************************************************************************
+/* SequenceInputStreamTest.java -- Tests SequenceInputStream's
+/*
+/* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU General Public License as published
+/* by the Free Software Foundation, version 2. (see COPYING)
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/* GNU General Public License for more details.
+/*
+/* You should have received a copy of the GNU General Public License
+/* along with this program; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+import java.io.*;
+
+public class SequenceInputStreamTest
+{
+
+public static void
+main(String argv[])
+{
+ System.out.println("Started test of SequenceInputStream");
+
+ String str1 = "I don't believe in going to chain restaurants. I think\n" +
+ "they are evil. I can't believe all the suburban folks who go to \n";
+
+ String str2 = "places like the Olive Garden. Not only does the food make\n" +
+ "me want to puke, non of these chains has the slightest bit of character.\n";
+
+ byte[] buf = new byte[10];
+
+ System.out.println("Test 1: Simple read test");
+ try
+ {
+ StringBufferInputStream is1 = new StringBufferInputStream(str1);
+ ByteArrayInputStream is2 = new ByteArrayInputStream(str2.getBytes());
+ SequenceInputStream sis = new SequenceInputStream(is1, is2);
+
+ int bytes_read;
+ while((bytes_read = sis.read(buf)) != -1)
+ {
+ System.out.print(new String(buf,0,bytes_read));
+ }
+
+ sis.close();
+ System.out.println("PASSED: Simple read test");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: Simple read test: " + e);
+ }
+
+ System.out.println("Test 2: close() test");
+
+ try
+ {
+ StringBufferInputStream is1 = new StringBufferInputStream(str1);
+ ByteArrayInputStream is2 = new ByteArrayInputStream(str2.getBytes());
+ SequenceInputStream sis = new SequenceInputStream(is1, is2);
+
+ sis.read(buf);
+ sis.close();
+ if (sis.read() != -1)
+ System.out.println("FAILED: close() test");
+ else
+ System.out.println("PASSED: close() test");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: close() test: " + e);
+ }
+
+ System.out.println("Finished test of SequenceInputStream");
+}
+
+} // class SequenceInputStream
+
diff --git a/test/java.io/StringBufferInputStreamTest.java b/test/java.io/StringBufferInputStreamTest.java
new file mode 100644
index 000000000..82d13af81
--- /dev/null
+++ b/test/java.io/StringBufferInputStreamTest.java
@@ -0,0 +1,161 @@
+/*************************************************************************
+/* StringBufferInputStreamTest.java -- Test StringBufferInputStream's of course
+/*
+/* Copyright (c) 1998 by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This program is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU General Public License as published
+/* by the Free Software Foundation, version 2. (see COPYING)
+/*
+/* This program is distributed in the hope that it will be useful, but
+/* WITHOUT ANY WARRANTY; without even the implied warranty of
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/* GNU General Public License for more details.
+/*
+/* You should have received a copy of the GNU General Public License
+/* along with this program; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+import java.io.*;
+
+public class StringBufferInputStreamTest extends StringBufferInputStream
+{
+
+public
+StringBufferInputStreamTest(String b)
+{
+ super(b);
+}
+
+public static void
+main(String[] argv)
+{
+ System.out.println("Starting test of StringBufferInputStream.");
+ System.out.flush();
+
+ String str = "Between my freshman and sophomore years of high school\n" +
+ "we moved into a brand new building. The old high school was turned\n" +
+ "into an elementary school.\n";
+
+ System.out.println("Test 1: Protected Variables");
+
+ StringBufferInputStreamTest sbis = new StringBufferInputStreamTest(str);
+ byte[] read_buf = new byte[12];
+
+ try
+ {
+ sbis.read(read_buf);
+ sbis.mark(0);
+
+ boolean passed = true;
+
+ sbis.read(read_buf);
+ if (sbis.pos != (read_buf.length * 2))
+ {
+ passed = false;
+ System.out.println("The pos variable is wrong. Expected 24 and got " +
+ sbis.pos);
+ }
+ if (sbis.count != str.length())
+ {
+ passed = false;
+ System.out.println("The count variable is wrong. Expected " +
+ str.length() + " and got " + sbis.pos);
+ }
+ if (sbis.buffer != str)
+ {
+ passed = false;
+ System.out.println("The buf variable is not correct");
+ }
+
+ if (passed)
+ System.out.println("PASSED: Protected Variables Test");
+ else
+ System.out.println("FAILED: Protected Variables Test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: Protected Variables Test: " + e);
+ }
+
+ System.out.println("Test 2: Simple Read Test");
+
+ sbis = new StringBufferInputStreamTest(str);
+
+ try
+ {
+ int bytes_read, total_read = 0;
+ while ((bytes_read = sbis.read(read_buf, 0, read_buf.length)) != -1)
+ {
+ System.out.print(new String(read_buf, 0, bytes_read));
+ total_read += bytes_read;
+ }
+
+ sbis.close();
+ if (total_read == str.length())
+ System.out.println("PASSED: Simple Read Test");
+ else
+ System.out.println("FAILED: Simple Read Test");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FAILED: Simple Read Test: " + e);
+ }
+
+ System.out.println("Test 3: mark/reset/available/skip test");
+ sbis = new StringBufferInputStreamTest(str);
+
+ try
+ {
+ boolean passed = true;
+
+ sbis.read(read_buf);
+ if (sbis.available() != (str.length() - read_buf.length))
+ {
+ passed = false;
+ System.out.println("available() reported " + sbis.available() +
+ " and " + (str.length() - read_buf.length) +
+ " was expected");
+ }
+
+ if (sbis.skip(5) != 5)
+ {
+ passed = false;
+ System.out.println("skip() didn't work");
+ }
+ if (sbis.available() != (str.length() - (read_buf.length + 5)))
+ {
+ passed = false;
+ System.out.println("skip() lied");
+ }
+
+ if (sbis.markSupported())
+ {
+ passed = false;
+ System.out.println("markSupported() should have returned false but returned true");
+ }
+
+ int availsave = sbis.available();
+ sbis.reset();
+ if (sbis.pos != 0)
+ {
+ passed = false;
+ System.out.println("mark/reset failed to work");
+ }
+
+ if (passed)
+ System.out.println("PASSED: mark/reset/available/skip test");
+ else
+ System.out.println("FAILED: mark/reset/available/skip test");
+ }
+ catch(IOException e)
+ {
+ System.out.println("FAILED: mark/reset/available/skip test: " + e);
+ }
+
+ System.out.println("Finished StringBufferInputStream test");
+}
+
+}
+
diff --git a/test/java.io/dataoutput-jdk.out b/test/java.io/dataoutput-jdk.out
new file mode 100644
index 000000000..1fd7b7a38
--- /dev/null
+++ b/test/java.io/dataoutput-jdk.out
Binary files differ