Skip to content

Commit 51f6851

Browse files
committed
Merge branch '2.13'
2 parents c4ee2f8 + 2b9f89c commit 51f6851

File tree

2 files changed

+81
-9
lines changed

2 files changed

+81
-9
lines changed

src/test/java/com/fasterxml/jackson/failing/ParserErrorHandlingTest.java renamed to src/test/java/com/fasterxml/jackson/failing/ParserErrorHandling105Test.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44
import com.fasterxml.jackson.core.exc.StreamReadException;
55

66
// Failing tests for non-root-token problem
7-
public class ParserErrorHandlingTest
7+
public class ParserErrorHandling105Test
88
extends com.fasterxml.jackson.core.BaseTest
99
{
1010
// Tests for [core#105] ("eager number parsing misses errors")
11-
public void testMangledIntsBytes() {
12-
_testMangledNonRootInts(MODE_INPUT_STREAM);
13-
_testMangledNonRootInts(MODE_INPUT_STREAM_THROTTLED);
14-
11+
public void testMangledIntsBytes() throws Exception {
1512
// 02-Jun-2017, tatu: Fails to fail; should check whether this is expected
1613
// (since DataInput can't do look-ahead)
17-
// _testMangledNonRootInts(MODE_DATA_INPUT);
14+
_testMangledNonRootInts(MODE_DATA_INPUT);
1815
}
1916

20-
public void testMangledFloatsBytes() {
21-
_testMangledNonRootFloats(MODE_INPUT_STREAM);
22-
_testMangledNonRootFloats(MODE_INPUT_STREAM_THROTTLED);
17+
public void testMangledFloatsBytes() throws Exception {
18+
// _testMangledNonRootFloats(MODE_INPUT_STREAM);
19+
// _testMangledNonRootFloats(MODE_INPUT_STREAM_THROTTLED);
2320

2421
// 02-Jun-2017, tatu: Fails as expected, unlike int one. Bit puzzling...
2522
_testMangledNonRootFloats(MODE_DATA_INPUT);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.core.JsonParser;
4+
import com.fasterxml.jackson.core.JsonToken;
5+
import com.fasterxml.jackson.core.exc.StreamReadException;
6+
7+
public class ParserErrorHandling679Test
8+
extends com.fasterxml.jackson.core.BaseTest
9+
{
10+
// [core#679]
11+
public void testNonRootMangledFloats679Bytes() throws Exception {
12+
_testNonRootMangledFloats679(MODE_INPUT_STREAM);
13+
_testNonRootMangledFloats679(MODE_INPUT_STREAM_THROTTLED);
14+
_testNonRootMangledFloats679(MODE_DATA_INPUT);
15+
}
16+
17+
// [core#679]
18+
public void testNonRootMangledFloats679Chars() throws Exception {
19+
_testNonRootMangledFloats679(MODE_READER);
20+
}
21+
22+
// [core#679]
23+
public void testNonRootMangledInts679Bytes() throws Exception {
24+
_testNonRootMangledInts(MODE_INPUT_STREAM);
25+
_testNonRootMangledInts(MODE_INPUT_STREAM_THROTTLED);
26+
_testNonRootMangledInts(MODE_DATA_INPUT);
27+
_testNonRootMangledInts(MODE_READER);
28+
}
29+
30+
/*
31+
/**********************************************************************
32+
/* Helper methods
33+
/**********************************************************************
34+
*/
35+
36+
private void _testNonRootMangledFloats679(int mode) throws Exception {
37+
_testNonRootMangledFloats679(mode, "1.5x");
38+
_testNonRootMangledFloats679(mode, "1.5.00");
39+
}
40+
41+
private void _testNonRootMangledFloats679(int mode, String value) throws Exception
42+
{
43+
// Also test with floats
44+
JsonParser p = createParser(mode, "[ "+value+" ]");
45+
assertEquals(JsonToken.START_ARRAY, p.nextToken());
46+
try {
47+
JsonToken t = p.nextToken();
48+
Double v = p.getDoubleValue();
49+
fail("Should have gotten an exception for '"+value+"'; instead got ("+t+") number: "+v);
50+
} catch (StreamReadException e) {
51+
verifyException(e, "expected ");
52+
}
53+
p.close();
54+
}
55+
56+
private void _testNonRootMangledInts(int mode) throws Exception {
57+
_testNonRootMangledInts(mode, "100k");
58+
_testNonRootMangledInts(mode, "100/");
59+
}
60+
61+
private void _testNonRootMangledInts(int mode, String value) throws Exception
62+
{
63+
// Also test with floats
64+
JsonParser p = createParser(mode, "[ "+value+" ]");
65+
assertEquals(JsonToken.START_ARRAY, p.nextToken());
66+
try {
67+
JsonToken t = p.nextToken();
68+
int v = p.getIntValue();
69+
fail("Should have gotten an exception for '"+value+"'; instead got ("+t+") number: "+v);
70+
} catch (StreamReadException e) {
71+
verifyException(e, "expected ");
72+
}
73+
p.close();
74+
}
75+
}

0 commit comments

Comments
 (0)