Fixed empty CodePointCharStream throwing exception on getText. Fixes #1949
This commit is contained in:
parent
590fa8394c
commit
ac9f75303e
|
@ -23,6 +23,7 @@ public class TestCodePointCharStream {
|
|||
CodePointCharStream s = CharStreams.fromString("");
|
||||
assertEquals(0, s.size());
|
||||
assertEquals(0, s.index());
|
||||
assertEquals("", s.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -151,8 +151,8 @@ public abstract class CodePointCharStream implements CharStream {
|
|||
/** Return the UTF-16 encoded string for the given interval */
|
||||
@Override
|
||||
public String getText(Interval interval) {
|
||||
int startIdx = Math.min(interval.a, size - 1);
|
||||
int len = Math.min(interval.b - interval.a + 1, size);
|
||||
int startIdx = Math.min(interval.a, size);
|
||||
int len = Math.min(interval.b - interval.a + 1, size - startIdx);
|
||||
|
||||
// We know the maximum code point in byteArray is U+00FF,
|
||||
// so we can treat this as if it were ISO-8859-1, aka Latin-1,
|
||||
|
|
Loading…
Reference in New Issue