Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2841,9 +2841,9 @@ private final int _decodeChunkedUTF8_4(int c) throws IOException

protected final boolean loadMore() throws IOException
{
_currInputProcessed += _inputEnd;

if (_inputStream != null) {
_currInputProcessed += _inputEnd;

int count = _inputStream.read(_inputBuffer, 0, _inputBuffer.length);
if (count > 0) {
_inputPtr = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,34 @@ private void _testMedium(int len) throws Exception
p.close();
}

public void testCurrentLocationByteOffset() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
CBORGenerator gen = cborGenerator(out);
gen.writeString("1234567890");
gen.writeString("1234567890");
gen.close();

final byte[] b = out.toByteArray();

JsonParser p = cborParser(b);

assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals(1, p.getCurrentLocation().getByteOffset());
p.getText(); // fully read token.
assertEquals(11, p.getCurrentLocation().getByteOffset());

assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals(12, p.getCurrentLocation().getByteOffset());
p.getText();
assertEquals(22, p.getCurrentLocation().getByteOffset());

assertNull(p.nextToken());
assertEquals(22, p.getCurrentLocation().getByteOffset());

p.close();
assertEquals(22, p.getCurrentLocation().getByteOffset());
}

public void testLongNonChunkedText() throws Exception
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
Expand Down