1
- package com .fasterxml .jackson .databind .deser ;
1
+ package com .fasterxml .jackson .databind .deser . jdk ;
2
2
3
3
import java .math .BigDecimal ;
4
4
import java .math .BigInteger ;
11
11
12
12
import com .fasterxml .jackson .databind .ObjectMapper ;
13
13
import com .fasterxml .jackson .databind .json .JsonMapper ;
14
- import com .fasterxml .jackson .databind .testutil .DatabindTestUtil . DoubleWrapper ;
14
+ import com .fasterxml .jackson .databind .testutil .DatabindTestUtil ;
15
15
16
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
16
17
import static org .junit .jupiter .api .Assertions .assertNotNull ;
17
18
import static org .junit .jupiter .api .Assertions .fail ;
18
19
19
- import static com .fasterxml .jackson .databind .testutil .DatabindTestUtil .newJsonMapper ;
20
- import static com .fasterxml .jackson .databind .testutil .DatabindTestUtil .verifyException ;
21
-
22
20
public class BigNumbersDeserTest
21
+ extends DatabindTestUtil
23
22
{
24
23
static class BigIntegerWrapper {
25
24
public BigInteger number ;
@@ -31,7 +30,7 @@ static class BigDecimalWrapper {
31
30
32
31
/*
33
32
/**********************************************************
34
- /* Tests
33
+ /* Test methods
35
34
/**********************************************************
36
35
*/
37
36
@@ -103,6 +102,33 @@ public void testBigIntegerUnlimited() throws Exception
103
102
assertNotNull (bdw );
104
103
}
105
104
105
+ // [databind#4435]
106
+ @ Test
107
+ public void testNumberStartingWithDot () throws Exception
108
+ {
109
+ String num = ".555555555555555555555555555555" ;
110
+ BigDecimalWrapper w = MAPPER .readValue ("{\" number\" :\" " + num + "\" }" , BigDecimalWrapper .class );
111
+ assertEquals (new BigDecimal (num ), w .number );
112
+ }
113
+
114
+ // [databind#4435]
115
+ @ Test
116
+ public void testNumberStartingWithMinusDot () throws Exception
117
+ {
118
+ String num = "-.555555555555555555555555555555" ;
119
+ BigDecimalWrapper w = MAPPER .readValue ("{\" number\" :\" " + num + "\" }" , BigDecimalWrapper .class );
120
+ assertEquals (new BigDecimal (num ), w .number );
121
+ }
122
+
123
+ // [databind#4435]
124
+ @ Test
125
+ public void testNumberStartingWithPlusDot () throws Exception
126
+ {
127
+ String num = "+.555555555555555555555555555555" ;
128
+ BigDecimalWrapper w = MAPPER .readValue ("{\" number\" :\" " + num + "\" }" , BigDecimalWrapper .class );
129
+ assertEquals (new BigDecimal (num ), w .number );
130
+ }
131
+
106
132
private String generateJson (final String fieldName ) {
107
133
final int len = 1200 ;
108
134
final StringBuilder sb = new StringBuilder ();
0 commit comments