Skip to content

Commit 3387ecb

Browse files
authored
Add failing test for #4694 (#4695)
1 parent eeb4fdd commit 3387ecb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.math.BigDecimal;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import com.fasterxml.jackson.databind.*;
8+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
9+
10+
import static org.junit.Assert.assertEquals;
11+
12+
public class BigDecimalParsing4694Test extends DatabindTestUtil
13+
{
14+
private final String BIG_DEC_STR;
15+
{
16+
StringBuilder sb = new StringBuilder("-1234.");
17+
// Above 500 chars we get a problem:
18+
for (int i = 520; --i >= 0; ) {
19+
sb.append('0');
20+
}
21+
BIG_DEC_STR = sb.toString();
22+
}
23+
24+
private final ObjectMapper MAPPER = newJsonMapper();
25+
26+
// [databind#4694]: decoded wrong by jackson-core/FDP for over 500 char numbers
27+
@Test
28+
public void bigDecimal4694FromString() throws Exception
29+
{
30+
assertEquals(new BigDecimal(BIG_DEC_STR),
31+
MAPPER.readValue(BIG_DEC_STR, BigDecimal.class));
32+
}
33+
34+
@Test
35+
public void bigDecimal4694FromBytes() throws Exception
36+
{
37+
byte[] b = utf8Bytes(BIG_DEC_STR);
38+
assertEquals(new BigDecimal(BIG_DEC_STR),
39+
MAPPER.readValue(b, 0, b.length, BigDecimal.class));
40+
}
41+
}

0 commit comments

Comments
 (0)