This repository was archived by the owner on Jan 22, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
main/java/com/fasterxml/jackson/dataformat/cbor
test/java/com/fasterxml/jackson/dataformat/cbor Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -2841,9 +2841,9 @@ private final int _decodeChunkedUTF8_4(int c) throws IOException
2841
2841
2842
2842
protected final boolean loadMore () throws IOException
2843
2843
{
2844
- _currInputProcessed += _inputEnd ;
2845
-
2846
2844
if (_inputStream != null ) {
2845
+ _currInputProcessed += _inputEnd ;
2846
+
2847
2847
int count = _inputStream .read (_inputBuffer , 0 , _inputBuffer .length );
2848
2848
if (count > 0 ) {
2849
2849
_inputPtr = 0 ;
Original file line number Diff line number Diff line change @@ -240,6 +240,34 @@ private void _testMedium(int len) throws Exception
240
240
p .close ();
241
241
}
242
242
243
+ public void testCurrentLocationByteOffset () throws Exception {
244
+ ByteArrayOutputStream out = new ByteArrayOutputStream ();
245
+ CBORGenerator gen = cborGenerator (out );
246
+ gen .writeString ("1234567890" );
247
+ gen .writeString ("1234567890" );
248
+ gen .close ();
249
+
250
+ final byte [] b = out .toByteArray ();
251
+
252
+ JsonParser p = cborParser (b );
253
+
254
+ assertToken (JsonToken .VALUE_STRING , p .nextToken ());
255
+ assertEquals (1 , p .getCurrentLocation ().getByteOffset ());
256
+ p .getText (); // fully read token.
257
+ assertEquals (11 , p .getCurrentLocation ().getByteOffset ());
258
+
259
+ assertToken (JsonToken .VALUE_STRING , p .nextToken ());
260
+ assertEquals (12 , p .getCurrentLocation ().getByteOffset ());
261
+ p .getText ();
262
+ assertEquals (22 , p .getCurrentLocation ().getByteOffset ());
263
+
264
+ assertNull (p .nextToken ());
265
+ assertEquals (22 , p .getCurrentLocation ().getByteOffset ());
266
+
267
+ p .close ();
268
+ assertEquals (22 , p .getCurrentLocation ().getByteOffset ());
269
+ }
270
+
243
271
public void testLongNonChunkedText () throws Exception
244
272
{
245
273
ByteArrayOutputStream out = new ByteArrayOutputStream ();
You can’t perform that action at this time.
0 commit comments