-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eeb4fdd
commit 8dda2f4
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/test/java/com/fasterxml/jackson/failing/BigDecimalParsing4694Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class BigDecimalParsing4694Test extends DatabindTestUtil | ||
{ | ||
private final String BIG_DEC_STR; | ||
{ | ||
StringBuilder sb = new StringBuilder("-1234."); | ||
// Above 500 chars we get a problem: | ||
for (int i = 520; --i >= 0; ) { | ||
sb.append('0'); | ||
} | ||
BIG_DEC_STR = sb.toString(); | ||
} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
// [databind#4694]: decoded wrong by jackson-core/FDP for over 500 char numbers | ||
@Test | ||
public void bigDecimal4694FromString() throws Exception | ||
{ | ||
assertEquals(new BigDecimal(BIG_DEC_STR), | ||
MAPPER.readValue(BIG_DEC_STR, BigDecimal.class)); | ||
} | ||
|
||
@Test | ||
public void bigDecimal4694FromBytes() throws Exception | ||
{ | ||
byte[] b = utf8Bytes(BIG_DEC_STR); | ||
assertEquals(new BigDecimal(BIG_DEC_STR), | ||
MAPPER.readValue(b, 0, b.length, BigDecimal.class)); | ||
} | ||
} |