Skip to content

Commit 9e11fe6

Browse files
committed
Test improvements wrt location handling in 2.13
1 parent 4fc15f4 commit 9e11fe6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/ParserInputStreamTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.SequenceInputStream;
77

88
import com.fasterxml.jackson.core.JsonFactory;
9+
import com.fasterxml.jackson.core.JsonLocation;
910
import com.fasterxml.jackson.core.JsonParser;
1011

1112
import com.fasterxml.jackson.databind.JsonNode;
@@ -48,9 +49,13 @@ public void testInputStreamWithHugeValueThatOverlaps() throws Exception {
4849
parser.nextToken();
4950
parser.finishToken();
5051

51-
final long start = parser.getCurrentLocation().getByteOffset();
52+
JsonLocation loc = parser.getCurrentLocation();
53+
final long start = loc.getByteOffset();
5254
assertEquals(7999, start);
5355

56+
assertEquals("byte offset: #7999", loc.offsetDescription());
57+
assertEquals("(ByteArrayInputStream)", loc.sourceDescription());
58+
5459
parser.nextToken();
5560
parser.finishToken();
5661

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/fuzz/Fuzz32527ShortUnicodeTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public void testInvalidShortUnicode() throws Exception
3939
verifyException(e, "Truncated UTF-8 character in Short Unicode String");
4040
verifyException(e, "(12 bytes)");
4141
verifyException(e, "byte 0xE5 at offset #10 indicated 2 more bytes needed");
42+
verifyException(e, "(byte[])"); // source description for raw source
43+
verifyException(e, "[29 bytes]"); // - "" -
44+
verifyException(e, "byte offset: #29"); // with 2.13 we get this too
4245
}
4346
}
4447
}

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/parse/ParserLocationTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public void testSimpleOffsets() throws IOException
2626
// but first 4 bytes are for header
2727
assertEquals(4, loc.getByteOffset());
2828

29+
// Let's verify Location info (quite minimal for Binary content)
30+
assertEquals("byte offset: #4", loc.offsetDescription());
31+
assertEquals("(byte[])[12 bytes]", loc.sourceDescription());
32+
2933
// array marker is a single byte, so:
3034
assertToken(JsonToken.START_ARRAY, p.nextToken());
3135
assertEquals(5, p.getCurrentLocation().getByteOffset());

0 commit comments

Comments
 (0)