use of java.io.PushbackReader in project j2objc by google.
the class OldPushbackReaderTest method test_unreadI.
/**
* java.io.PushbackReader#unread(int)
*/
public void test_unreadI() throws IOException {
PushbackReader tobj;
tobj = new PushbackReader(underlying);
// Why does this work?!?
tobj.unread(23);
tobj.skip(2);
tobj.unread(23);
assertEquals("Wrong value read!", 23, tobj.read());
tobj.unread(13);
try {
tobj.unread(13);
fail("IOException not thrown (ACTUALLY NOT SURE WHETHER IT REALLY MUST BE THROWN!).");
} catch (IOException e) {
// expected
}
}
use of java.io.PushbackReader in project j2objc by google.
the class OldPushbackReaderTest method test_read.
/**
* java.io.PushbackReader#read()
*/
public void test_read() throws IOException {
PushbackReader tobj;
tobj = new PushbackReader(underlying);
assertEquals("Wrong value read!", 66, tobj.read());
underlying.throwExceptionOnNextUse = true;
try {
tobj.read();
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
}
use of java.io.PushbackReader in project j2objc by google.
the class OldPushbackReaderTest method test_read$CII.
/**
* java.io.PushbackReader#read(char[], int, int)
*/
public void test_read$CII() throws IOException {
PushbackReader tobj;
char[] buf = ("01234567890123456789").toCharArray();
tobj = new PushbackReader(underlying);
tobj.read(buf, 6, 5);
assertEquals("Wrong value read!", "BEGIN", new String(buf, 6, 5));
assertEquals("Too much read!", "012345BEGIN123456789", new String(buf));
underlying.throwExceptionOnNextUse = true;
try {
tobj.read(buf, 6, 5);
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
// Test for method int java.io.PushbackReader.read(char [], int, int)
try {
char[] c = new char[5];
pbr.read(c, 0, 5);
assertTrue("Failed to read chars", new String(c).equals(pbString.substring(0, 5)));
assertEquals(0, pbr.read(c, 0, 0));
assertEquals(c.length, pbr.read(c, 0, c.length));
assertEquals(0, pbr.read(c, c.length, 0));
} catch (IOException e) {
fail("IOException during read test : " + e.getMessage());
}
}
use of java.io.PushbackReader in project j2objc by google.
the class OldPushbackReaderTest method test_read_$CII_Exception.
/**
* java.io.PushbackReader#read(char[], int, int)
*/
public void test_read_$CII_Exception() throws IOException {
pbr = new PushbackReader(new StringReader(pbString), 10);
char[] nullCharArray = null;
char[] charArray = new char[10];
try {
pbr.read(nullCharArray, 0, 1);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
pbr.read(charArray, 0, -1);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
pbr.read(charArray, -1, 0);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
pbr.read(charArray, charArray.length + 1, 0);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
pbr.read(charArray, charArray.length, 1);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
pbr.read(charArray, 1, charArray.length);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
pbr.read(charArray, 0, charArray.length + 1);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
pbr.close();
try {
pbr.read(charArray, 0, 1);
fail("should throw IOException");
} catch (IOException e) {
// expected
}
}
use of java.io.PushbackReader in project j2objc by google.
the class OldPushbackReaderTest method test_unread$C.
/**
* java.io.PushbackReader#unread(char[])
*/
public void test_unread$C() throws IOException {
PushbackReader tobj;
String str2 = "0123456789";
char[] buf2 = str2.toCharArray();
char[] readBuf = new char[10];
tobj = new PushbackReader(underlying, 10);
tobj.unread(buf2);
try {
tobj.unread(buf2);
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
tobj.read(readBuf);
assertEquals("Incorrect bytes read", str2, new String(readBuf));
underlying.throwExceptionOnNextUse = true;
try {
tobj.read(buf2);
fail("IOException not thrown.");
} catch (IOException e) {
// expected
}
// Test for method void java.io.PushbackReader.unread(char [])
try {
char[] c = new char[5];
pbr.read(c, 0, 5);
pbr.unread(c);
pbr.read(c, 0, 5);
assertTrue("Failed to unread chars", new String(c).equals(pbString.substring(0, 5)));
} catch (IOException e) {
fail("IOException during read test : " + e.getMessage());
}
}
Aggregations