Search in sources :

Example 1 with CharSequenceReader

use of org.eclipse.wst.sse.core.internal.text.CharSequenceReader in project webtools.sourceediting by eclipse.

the class TestCharSequenceReader method testStandardBeginning.

public void testStandardBeginning() {
    CharSequenceReader reader = new CharSequenceReader(fStandardString, 0, 3);
    char char1 = (char) reader.read();
    assertTrue(char1 == 't');
    char char2 = (char) reader.read();
    assertTrue(char2 == 'e');
    char char3 = (char) reader.read();
    assertTrue(char3 == 's');
    int eof = reader.read();
    assertTrue(eof == -1);
}
Also used : CharSequenceReader(org.eclipse.wst.sse.core.internal.text.CharSequenceReader)

Example 2 with CharSequenceReader

use of org.eclipse.wst.sse.core.internal.text.CharSequenceReader in project webtools.sourceediting by eclipse.

the class TestCharSequenceReader method testStandardMiddle.

public void testStandardMiddle() {
    CharSequenceReader reader = new CharSequenceReader(fStandardString, 2, 3);
    char char1 = (char) reader.read();
    assertTrue(char1 == 's');
    char char2 = (char) reader.read();
    assertTrue(char2 == 't');
    char char3 = (char) reader.read();
    assertTrue(char3 == '1');
    int eof = reader.read();
    assertTrue(eof == -1);
}
Also used : CharSequenceReader(org.eclipse.wst.sse.core.internal.text.CharSequenceReader)

Example 3 with CharSequenceReader

use of org.eclipse.wst.sse.core.internal.text.CharSequenceReader in project webtools.sourceediting by eclipse.

the class TestCharSequenceReader method testBufferBegining.

public void testBufferBegining() throws IOException {
    CharSequenceReader reader = new CharSequenceReader(fStandardString, 0, 3);
    String targetString = "tes";
    // intentionally small sized buffer
    char[] charbuffer = new char[2];
    StringBuffer stringBuffer = new StringBuffer();
    int nRead = 0;
    while (nRead != -1) {
        nRead = reader.read(charbuffer);
        if (nRead > 0) {
            stringBuffer.append(charbuffer, 0, nRead);
        }
    }
    String testString = stringBuffer.toString();
    assertEquals(targetString, testString);
}
Also used : CharSequenceReader(org.eclipse.wst.sse.core.internal.text.CharSequenceReader)

Example 4 with CharSequenceReader

use of org.eclipse.wst.sse.core.internal.text.CharSequenceReader in project webtools.sourceediting by eclipse.

the class TestCharSequenceReader method testBufferEnd.

public void testBufferEnd() throws IOException {
    CharSequenceReader reader = new CharSequenceReader(fStandardString, 4, 3);
    String targetString = "123";
    // intentionally small sized buffer
    char[] charbuffer = new char[2];
    StringBuffer stringBuffer = new StringBuffer();
    int nRead = 0;
    while (nRead != -1) {
        nRead = reader.read(charbuffer);
        if (nRead > 0) {
            stringBuffer.append(charbuffer, 0, nRead);
        }
    }
    String testString = stringBuffer.toString();
    assertEquals(targetString, testString);
}
Also used : CharSequenceReader(org.eclipse.wst.sse.core.internal.text.CharSequenceReader)

Example 5 with CharSequenceReader

use of org.eclipse.wst.sse.core.internal.text.CharSequenceReader in project webtools.sourceediting by eclipse.

the class TestCharSequenceReader method testStandardOutOfRange.

public void testStandardOutOfRange() {
    CharSequenceReader reader = new CharSequenceReader(fStandardString, 50, 3);
    int eof = reader.read();
    assertTrue(eof == -1);
}
Also used : CharSequenceReader(org.eclipse.wst.sse.core.internal.text.CharSequenceReader)

Aggregations

CharSequenceReader (org.eclipse.wst.sse.core.internal.text.CharSequenceReader)11 IDocument (org.eclipse.jface.text.IDocument)1 DocumentReader (org.eclipse.wst.sse.core.internal.document.DocumentReader)1