Search in sources :

Example 6 with CharArrayReader

use of java.io.CharArrayReader in project robovm by robovm.

the class OldCharArrayReaderTest method test_markI.

/**
     * java.io.CharArrayReader#mark(int)
     */
public void test_markI() throws IOException {
    cr = new CharArrayReader(hw);
    cr.skip(5L);
    cr.mark(100);
    cr.read();
    cr.reset();
    assertEquals("Test 1: Failed to mark correct position;", 'W', cr.read());
    cr.close();
    try {
        cr.mark(100);
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
}
Also used : CharArrayReader(java.io.CharArrayReader) IOException(java.io.IOException)

Example 7 with CharArrayReader

use of java.io.CharArrayReader in project robovm by robovm.

the class OldCharArrayReaderTest method test_read$CII.

/**
     * java.io.CharArrayReader#read(char[], int, int)
     */
public void test_read$CII() throws IOException {
    // Test for method int java.io.CharArrayReader.read(char [], int, int)
    char[] c = new char[11];
    cr = new CharArrayReader(hw);
    cr.read(c, 1, 10);
    assertTrue("Test 1: Read returned incorrect chars.", new String(c, 1, 10).equals(new String(hw, 0, 10)));
    // Illegal argument checks.
    try {
        cr.read(null, 1, 0);
        fail("Test 2: NullPointerException expected.");
    } catch (NullPointerException e) {
    // Expected.
    }
    try {
        cr.read(c, -1, 1);
        fail("Test 3: ArrayIndexOutOfBoundsException expected.");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    try {
        cr.read(c, 1, -1);
        fail("Test 4: ArrayIndexOutOfBoundsException expected.");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    try {
        cr.read(c, 1, c.length);
        fail("Test 5: ArrayIndexOutOfBoundsException expected.");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    cr.close();
    try {
        cr.read(c, 1, 1);
        fail("Test 6: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
}
Also used : CharArrayReader(java.io.CharArrayReader) IOException(java.io.IOException)

Example 8 with CharArrayReader

use of java.io.CharArrayReader in project robovm by robovm.

the class OldAndroidCharArrayReaderTest method testCharArrayReader.

public void testCharArrayReader() throws Exception {
    String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
    CharArrayReader a = new CharArrayReader(str.toCharArray());
    CharArrayReader b = new CharArrayReader(str.toCharArray());
    CharArrayReader c = new CharArrayReader(str.toCharArray());
    CharArrayReader d = new CharArrayReader(str.toCharArray());
    Assert.assertEquals(str, read(a));
    Assert.assertEquals("AbCdEfGhIj", read(b, 10));
    Assert.assertEquals("bdfhjlnprtvxz", skipRead(c));
    Assert.assertEquals("AbCdEfGdEfGhIjKlMnOpQrStUvWxYz", markRead(d, 3, 4));
}
Also used : CharArrayReader(java.io.CharArrayReader)

Example 9 with CharArrayReader

use of java.io.CharArrayReader in project j2objc by google.

the class OldCharArrayReaderTest method test_close.

/**
     * java.io.CharArrayReader#close()
     */
public void test_close() {
    cr = new CharArrayReader(hw);
    cr.close();
    try {
        cr.read();
        fail("Failed to throw exception on read from closed stream");
    } catch (IOException e) {
    // Expected.
    }
}
Also used : CharArrayReader(java.io.CharArrayReader) IOException(java.io.IOException)

Example 10 with CharArrayReader

use of java.io.CharArrayReader in project j2objc by google.

the class OldCharArrayReaderTest method test_Constructor$C.

/**
     * java.io.CharArrayReader#CharArrayReader(char[])
     */
public void test_Constructor$C() {
    try {
        cr = new CharArrayReader(hw);
        assertTrue("Failed to create reader", cr.ready());
    } catch (IOException e) {
        fail("Exception determining ready state : " + e.getMessage());
    }
}
Also used : CharArrayReader(java.io.CharArrayReader) IOException(java.io.IOException)

Aggregations

CharArrayReader (java.io.CharArrayReader)53 IOException (java.io.IOException)31 BufferedReader (java.io.BufferedReader)14 Reader (java.io.Reader)7 File (java.io.File)6 StringReader (java.io.StringReader)6 BufferedWriter (java.io.BufferedWriter)5 FileReader (java.io.FileReader)5 FileWriter (java.io.FileWriter)5 InputStreamReader (java.io.InputStreamReader)5 CharArrayWriter (java.io.CharArrayWriter)4 PipedReader (java.io.PipedReader)4 Support_StringReader (tests.support.Support_StringReader)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputSource (org.xml.sax.InputSource)3 XmlOffshoot (alma.demo.XmlOffshoot)2 XmlEntityStruct (alma.xmlentity.XmlEntityStruct)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2