use of java.io.StringReader in project j2objc by google.
the class OldBufferedReaderTest method test_readLine_interaction_with_read.
public void test_readLine_interaction_with_read() throws Exception {
BufferedReader r = new BufferedReader(new StringReader("1\r\n2"));
assertEquals('1', r.read());
assertEquals('\r', r.read());
// The '\r' we read() didn't count.
assertEquals("", r.readLine());
assertEquals("2", r.readLine());
assertNull(r.readLine());
}
use of java.io.StringReader in project j2objc by google.
the class OldLineNumberReaderTest method test_reset.
public void test_reset() throws IOException {
lnr = new LineNumberReader(new StringReader(text));
assertEquals("Test 1: Returned incorrect line number;", 0, lnr.getLineNumber());
String line = null;
lnr.mark(100);
lnr.readLine();
lnr.reset();
line = lnr.readLine();
assertEquals("Test 2: Failed to reset reader", "0", line);
lnr.mark(100);
lnr.close();
try {
lnr.reset();
fail("Test 3: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of java.io.StringReader in project j2objc by google.
the class OldLineNumberReaderTest method test_markI.
public void test_markI() throws IOException {
lnr = new LineNumberReader(new StringReader(text));
String line;
lnr.skip(80);
lnr.mark(100);
line = lnr.readLine();
lnr.reset();
assertTrue("Test 1: Failed to return to marked position.", line.equals(lnr.readLine()));
lnr.close();
try {
lnr.mark(42);
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
// The spec does not say the mark has to be invalidated
}
use of java.io.StringReader in project j2objc by google.
the class OldBufferedReaderTest method testSourceThrowsWithMark.
public void testSourceThrowsWithMark() throws IOException {
br = new BufferedReader(new ThrowingReader(new StringReader("ABCDEFGHI"), 4));
br.read();
br.read();
br.mark(10);
br.read();
br.read();
try {
br.read();
fail();
} catch (IOException fromThrowingReader) {
}
assertEquals('E', br.read());
assertEquals('F', br.read());
}
use of java.io.StringReader in project j2objc by google.
the class OldBufferedReaderTest method test_readLine_interaction_with_array_read_1.
public void test_readLine_interaction_with_array_read_1() throws Exception {
BufferedReader r = new BufferedReader(new StringReader("1\r\n2"));
assertEquals(2, r.read(new char[2], 0, 2));
// The '\r' we read() didn't count.
assertEquals("", r.readLine());
assertEquals("2", r.readLine());
assertNull(r.readLine());
}
Aggregations