Search in sources :

Example 11 with PushbackReader

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

the class OldPushbackReaderTest method test_unread$CII.

/**
     * java.io.PushbackReader#unread(char[], int, int)
     */
public void test_unread$CII() throws IOException {
    PushbackReader tobj;
    String str2 = "0123456789";
    char[] buf2 = (str2 + str2 + str2).toCharArray();
    char[] readBuf = new char[10];
    tobj = new PushbackReader(underlying, 10);
    tobj.unread(buf2, 15, 10);
    try {
        tobj.unread(buf2, 15, 10);
        fail("IOException not thrown.");
    } catch (IOException e) {
    // expected
    }
    tobj.read(readBuf);
    assertEquals("Incorrect bytes read", "5678901234", new String(readBuf));
    underlying.throwExceptionOnNextUse = true;
    try {
        tobj.read(buf2, 15, 10);
        fail("IOException not thrown.");
    } catch (IOException e) {
    // expected
    }
}
Also used : IOException(java.io.IOException) PushbackReader(java.io.PushbackReader)

Example 12 with PushbackReader

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

the class OldPushbackReaderTest method test_ConstructorLjava_io_Reader.

/**
     * java.io.PushbackReader#PushbackReader(java.io.Reader)
     */
public void test_ConstructorLjava_io_Reader() {
    // Test for method java.io.PushbackReader(java.io.Reader)
    try {
        pbr.close();
        pbr = new PushbackReader(new StringReader(pbString));
        char[] buf = new char[5];
        pbr.read(buf, 0, 5);
        pbr.unread(buf);
        fail("Created reader with buffer larger than 1");
        ;
    } catch (IOException e) {
    // Expected
    }
    try {
        pbr = new PushbackReader(null);
    } catch (NullPointerException e) {
    // EXpected
    }
}
Also used : StringReader(java.io.StringReader) IOException(java.io.IOException) PushbackReader(java.io.PushbackReader)

Example 13 with PushbackReader

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

the class OldPushbackReaderTest method test_ConstructorLjava_io_ReaderI.

/**
     * java.io.PushbackReader#PushbackReader(java.io.Reader, int)
     */
public void test_ConstructorLjava_io_ReaderI() throws IOException {
    PushbackReader tobj;
    tobj = new PushbackReader(underlying, 10000);
    tobj = new PushbackReader(underlying, 1);
    try {
        tobj = new PushbackReader(underlying, -1);
        tobj.close();
        fail("IOException not thrown.");
    } catch (IllegalArgumentException e) {
    // expected
    }
    try {
        tobj = new PushbackReader(underlying, 0);
        tobj.close();
        fail("IOException not thrown.");
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : PushbackReader(java.io.PushbackReader)

Example 14 with PushbackReader

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

the class OldPushbackReaderTest method test_close.

/**
     * java.io.PushbackReader#close()
     */
public void test_close() throws IOException {
    PushbackReader tobj;
    tobj = new PushbackReader(underlying);
    tobj.close();
    tobj.close();
    tobj = new PushbackReader(underlying);
    underlying.throwExceptionOnNextUse = true;
    try {
        tobj.close();
        fail("IOException not thrown.");
    } catch (IOException e) {
    // expected
    }
}
Also used : IOException(java.io.IOException) PushbackReader(java.io.PushbackReader)

Example 15 with PushbackReader

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

the class OldPushbackReaderTest method test_ready.

/**
     * java.io.PushbackReader#ready()
     */
public void test_ready() throws IOException {
    PushbackReader tobj;
    tobj = new PushbackReader(underlying);
    assertTrue("Should be ready!", tobj.ready());
    underlying.throwExceptionOnNextUse = true;
    try {
        tobj.ready();
        fail("IOException not thrown.");
    } catch (IOException e) {
    // expected
    }
}
Also used : IOException(java.io.IOException) PushbackReader(java.io.PushbackReader)

Aggregations

PushbackReader (java.io.PushbackReader)37 IOException (java.io.IOException)22 StringReader (java.io.StringReader)12 CompileException (com.googlecode.prolog_cafe.exceptions.CompileException)3 JavaObjectTerm (com.googlecode.prolog_cafe.lang.JavaObjectTerm)3 SymbolTerm (com.googlecode.prolog_cafe.lang.SymbolTerm)3 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3 StructureTerm (com.googlecode.prolog_cafe.lang.StructureTerm)2 FileNotFoundException (java.io.FileNotFoundException)2 LineNumberReader (java.io.LineNumberReader)2 Lexer (net.sourceforge.processdash.data.compiler.lexer.Lexer)2 Parser (net.sourceforge.processdash.data.compiler.parser.Parser)2 SyntaxException (com.googlecode.prolog_cafe.exceptions.SyntaxException)1 TermException (com.googlecode.prolog_cafe.exceptions.TermException)1 BufferingPrologControl (com.googlecode.prolog_cafe.lang.BufferingPrologControl)1 ListTerm (com.googlecode.prolog_cafe.lang.ListTerm)1 Term (com.googlecode.prolog_cafe.lang.Term)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1