Search in sources :

Example 11 with PeekReader

use of org.apache.jena.atlas.io.PeekReader in project jena by apache.

the class AbstractTestPeekReader method read9.

@Test
public void read9() {
    PeekReader r = make("a\nb\n");
    checkLineCol(r, INIT_LINE, INIT_COL);
    int x = r.peekChar();
    assertEquals('a', x);
    checkLineCol(r, INIT_LINE, INIT_COL);
    x = r.readChar();
    assertEquals('a', x);
    checkLineCol(r, INIT_LINE, INIT_COL + 1);
    x = r.readChar();
    assertEquals('\n', x);
    checkLineCol(r, INIT_LINE + 1, INIT_COL);
}
Also used : PeekReader(org.apache.jena.atlas.io.PeekReader) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 12 with PeekReader

use of org.apache.jena.atlas.io.PeekReader in project jena by apache.

the class AbstractTestPeekReader method read1.

@Test
public void read1() {
    PeekReader r = make("");
    checkLineCol(r, INIT_LINE, INIT_COL);
    int x = r.peekChar();
    assertEquals(-1, x);
    x = r.readChar();
    assertEquals(-1, x);
    x = r.readChar();
    assertEquals(-1, x);
}
Also used : PeekReader(org.apache.jena.atlas.io.PeekReader) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 13 with PeekReader

use of org.apache.jena.atlas.io.PeekReader in project jena by apache.

the class AbstractTestPeekReader method unread4.

@Test
public void unread4() {
    PeekReader r = make("");
    r.readChar();
    assertEquals(-1, r.peekChar());
    r.pushbackChar('0');
    r.pushbackChar('1');
    r.pushbackChar('2');
    r.pushbackChar('3');
    // Backwards!
    contains(r, "3210");
}
Also used : PeekReader(org.apache.jena.atlas.io.PeekReader) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 14 with PeekReader

use of org.apache.jena.atlas.io.PeekReader in project jena by apache.

the class AbstractTestPeekReader method unread3.

@Test
public void unread3() {
    PeekReader r = make("");
    r.readChar();
    assertEquals(-1, r.peekChar());
    r.pushbackChar('a');
    contains(r, "a");
}
Also used : PeekReader(org.apache.jena.atlas.io.PeekReader) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 15 with PeekReader

use of org.apache.jena.atlas.io.PeekReader in project jena by apache.

the class AbstractTestPeekReader method unread2.

@Test
public void unread2() {
    PeekReader r = make("abc");
    checkLineCol(r, INIT_LINE, INIT_COL);
    r.readChar();
    // Pushback does not move line/col backwards.
    checkLineCol(r, INIT_LINE, INIT_COL + 1);
    assertEquals('b', r.peekChar());
    checkLineCol(r, INIT_LINE, INIT_COL + 1);
    r.pushbackChar('a');
    checkLineCol(r, INIT_LINE, INIT_COL + 1);
    contains(r, "abc");
}
Also used : PeekReader(org.apache.jena.atlas.io.PeekReader) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Aggregations

PeekReader (org.apache.jena.atlas.io.PeekReader)22 BaseTest (org.apache.jena.atlas.junit.BaseTest)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)1 RiotException (org.apache.jena.riot.RiotException)1