use of tests.support.Support_StringReader in project robovm by robovm.
the class BufferedReaderTest method test_read_$CII_Exception.
/**
* @tests java.io.BufferedReader#read(char[], int, int)
*/
public void test_read_$CII_Exception() throws IOException {
br = new BufferedReader(new Support_StringReader(testString));
char[] nullCharArray = null;
char[] charArray = testString.toCharArray();
try {
br.read(nullCharArray, -1, -1);
fail();
} catch (NullPointerException expected) {
} catch (IndexOutOfBoundsException expected) {
}
try {
br.read(nullCharArray, -1, 0);
fail();
} catch (NullPointerException expected) {
} catch (IndexOutOfBoundsException expected) {
}
try {
br.read(nullCharArray, 0, -1);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
br.read(nullCharArray, 0, 0);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
br.read(nullCharArray, 0, 1);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
br.read(charArray, -1, -1);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
br.read(charArray, -1, 0);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// expected
}
br.read(charArray, 0, 0);
br.read(charArray, 0, charArray.length);
br.read(charArray, charArray.length, 0);
try {
br.read(charArray, charArray.length + 1, 0);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
//expected
}
try {
br.read(charArray, charArray.length + 1, 1);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
//expected
}
br.close();
try {
br.read(nullCharArray, -1, -1);
fail("should throw IOException");
} catch (IOException e) {
// expected
}
try {
br.read(charArray, -1, 0);
fail("should throw IOException");
} catch (IOException e) {
// expected
}
try {
br.read(charArray, 0, -1);
fail("should throw IOException");
} catch (IOException e) {
// expected
}
}
use of tests.support.Support_StringReader in project robovm by robovm.
the class BufferedReaderTest method test_reset.
/**
* @tests java.io.BufferedReader#reset()
*/
public void test_reset() {
// Test for method void java.io.BufferedReader.reset()
try {
br = new BufferedReader(new Support_StringReader(testString));
br.skip(500);
br.mark(900);
br.skip(500);
br.reset();
char[] buf = new char[testString.length()];
br.read(buf, 0, 500);
assertTrue("Failed to reset properly", testString.substring(500, 1000).equals(new String(buf, 0, 500)));
} catch (java.io.IOException e) {
fail("Exception during reset test");
}
try {
br = new BufferedReader(new Support_StringReader(testString));
br.skip(500);
br.reset();
fail("Reset succeeded on unmarked stream");
} catch (IOException x) {
return;
}
}
use of tests.support.Support_StringReader in project robovm by robovm.
the class BufferedReaderTest method test_readLine.
/**
* @tests java.io.BufferedReader#readLine()
*/
public void test_readLine() {
// Test for method java.lang.String java.io.BufferedReader.readLine()
try {
br = new BufferedReader(new Support_StringReader(testString));
String r = br.readLine();
assertEquals("readLine returned incorrect string", "Test_All_Tests", r);
} catch (java.io.IOException e) {
fail("Exception during readLine test");
}
}
use of tests.support.Support_StringReader in project robovm by robovm.
the class BufferedReaderTest method test_ready.
/**
* @tests java.io.BufferedReader#ready()
*/
public void test_ready() {
// Test for method boolean java.io.BufferedReader.ready()
try {
br = new BufferedReader(new Support_StringReader(testString));
assertTrue("ready returned false", br.ready());
} catch (java.io.IOException e) {
fail("Exception during ready test" + e.toString());
}
}
use of tests.support.Support_StringReader in project robovm by robovm.
the class BufferedReaderTest method assertLines.
private void assertLines(String in, String... lines) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new Support_StringReader(in));
for (String line : lines) {
assertEquals(line, bufferedReader.readLine());
}
assertNull(bufferedReader.readLine());
}
Aggregations