use of tests.support.Support_StringReader in project j2objc by google.
the class OldBufferedReaderTest method test_readLine.
public void test_readLine() throws IOException {
String line;
br = new BufferedReader(new Support_StringReader("Lorem\nipsum\rdolor sit amet..."));
line = br.readLine();
assertTrue("Test 1: Incorrect line written or read: " + line, line.equals("Lorem"));
line = br.readLine();
assertTrue("Test 2: Incorrect line written or read: " + line, line.equals("ipsum"));
line = br.readLine();
assertTrue("Test 3: Incorrect line written or read: " + line, line.equals("dolor sit amet..."));
br.close();
try {
br.readLine();
fail("Test 4: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_StringReader in project j2objc by google.
the class OldBufferedReaderTest method test_ConstructorLjava_io_Reader.
public void test_ConstructorLjava_io_Reader() {
// Test for method java.io.BufferedReader(java.io.Reader)
br = new BufferedReader(new Support_StringReader(testString));
assertNotNull(br);
}
use of tests.support.Support_StringReader in project j2objc by google.
the class OldBufferedReaderTest method test_markSupported.
public void test_markSupported() {
// Test for method boolean java.io.BufferedReader.markSupported()
br = new BufferedReader(new Support_StringReader(testString));
assertTrue("markSupported returned false.", br.markSupported());
}
use of tests.support.Support_StringReader in project j2objc by google.
the class OldBufferedReaderTest method test_close.
public void test_close() {
Support_ASimpleReader ssr = new Support_ASimpleReader(true);
try {
br = new BufferedReader(new Support_StringReader(testString));
br.close();
br.read();
fail("Test 1: Read on closed stream.");
} catch (IOException x) {
// Expected.
} catch (Exception e) {
fail("Exception during close test " + e.toString());
}
br = new BufferedReader(ssr);
try {
br.close();
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
// Avoid IOException in tearDown().
ssr.throwExceptionOnNextUse = false;
}
use of tests.support.Support_StringReader in project j2objc by google.
the class OldBufferedReaderTest method test_skipJ.
public void test_skipJ() throws IOException {
Support_ASimpleReader ssr = new Support_ASimpleReader(true);
br = new BufferedReader(new Support_StringReader(testString));
try {
br.skip(-1);
fail("Test 1: IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
br.skip(500);
char[] buf = new char[testString.length()];
br.read(buf, 0, 500);
assertTrue("Test 2: Failed to set skip properly.", testString.substring(500, 1000).equals(new String(buf, 0, 500)));
br.close();
br = new BufferedReader(ssr);
try {
br.skip(1);
fail("Test 3: IOException expected.");
} catch (IOException e) {
// Expected.
}
// Avoid IOException in tearDown().
ssr.throwExceptionOnNextUse = false;
}
Aggregations