use of tests.support.Support_ASimpleReader 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;
}
use of tests.support.Support_ASimpleReader in project j2objc by google.
the class OldReaderTest method test_Read_$C.
public void test_Read_$C() throws IOException {
Support_ASimpleReader simple;
simple = new Support_ASimpleReader("Bla bla, what else?");
char[] buf = new char[4];
assertEquals("Wrong return value!", 4, simple.read(buf));
assertEquals("Wrong stuff read!", "Bla ", new String(buf));
simple.read(buf);
assertEquals("Wrong stuff read!", "bla,", new String(buf));
simple.throwExceptionOnNextUse = true;
try {
simple.read(buf);
fail("IOException not thrown!");
} catch (IOException expected) {
}
}
use of tests.support.Support_ASimpleReader in project j2objc by google.
the class OldReaderTest method test_read.
public void test_read() throws IOException {
Support_ASimpleReader simple = new Support_ASimpleReader("Bla bla, what else?");
int res = simple.read();
assertEquals("Wrong stuff read!", 'B', res);
res = simple.read();
assertEquals("Wrong stuff read!", 'l', res);
simple.throwExceptionOnNextUse = true;
try {
simple.read();
fail("IOException not thrown!");
} catch (IOException expected) {
}
}
use of tests.support.Support_ASimpleReader in project j2objc by google.
the class OldReaderTest method test_skip.
public void test_skip() throws IOException {
Support_ASimpleReader simple = new Support_ASimpleReader("Bla bla, what else?");
char[] buf = new char[4];
simple.read(buf);
assertEquals("Wrong stuff read!", "Bla ", new String(buf));
simple.skip(5);
simple.read(buf);
assertEquals("Wrong stuff read!", "what", new String(buf));
simple.throwExceptionOnNextUse = true;
try {
simple.skip(1);
fail("IOException not thrown!");
} catch (IOException expected) {
}
}
use of tests.support.Support_ASimpleReader in project robovm by robovm.
the class OldBufferedReaderTest method test_read.
public void test_read() throws IOException {
Support_ASimpleReader ssr = new Support_ASimpleReader(true);
try {
br = new BufferedReader(new Support_StringReader(testString));
int r = br.read();
assertTrue("Char read improperly", testString.charAt(0) == r);
br = new BufferedReader(new Support_StringReader(new String(new char[] { '蝥' })));
assertTrue("Wrong double byte character", br.read() == '蝥');
} catch (java.io.IOException e) {
fail("Exception during read test");
}
char[] chars = new char[256];
for (int i = 0; i < 256; i++) chars[i] = (char) i;
Reader in = new BufferedReader(new Support_StringReader(new String(chars)), 12);
try {
// Fill the
assertEquals("Wrong initial char", 0, in.read());
// buffer
char[] buf = new char[14];
// Read greater than the buffer
in.read(buf, 0, 14);
assertTrue("Wrong block read data", new String(buf).equals(new String(chars, 1, 14)));
// Check next byte
assertEquals("Wrong chars", 15, in.read());
} catch (IOException e) {
fail("Exception during read test 2:" + e);
}
// regression test for HARMONY-841
assertTrue(new BufferedReader(new CharArrayReader(new char[5], 1, 0), 2).read() == -1);
br.close();
br = new BufferedReader(ssr);
try {
br.read();
fail("IOException expected.");
} catch (IOException e) {
// Expected.
}
// Avoid IOException in tearDown().
ssr.throwExceptionOnNextUse = false;
}
Aggregations