-
-
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.
add number test where num starts with a dot (#4436)
- Loading branch information
Showing
2 changed files
with
53 additions
and
24 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigDecimalDeser4435Test.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,49 @@ | ||
package com.fasterxml.jackson.databind.deser.jdk; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.json.JsonMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
// @since 2.16.3 | ||
public class BigDecimalDeser4435Test | ||
{ | ||
static class BigDecimalWrapper { | ||
public BigDecimal number; | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Tests | ||
/********************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = JsonMapper.builder().build(); | ||
|
||
@Test | ||
public void testNumberStartingWithDot() throws Exception | ||
{ | ||
String num = ".555555555555555555555555555555"; | ||
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class); | ||
assertEquals(new BigDecimal(num), w.number); | ||
} | ||
|
||
@Test | ||
public void testNumberStartingWithMinusDot() throws Exception | ||
{ | ||
String num = "-.555555555555555555555555555555"; | ||
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class); | ||
assertEquals(new BigDecimal(num), w.number); | ||
} | ||
|
||
@Test | ||
public void testNumberStartingWithPlusDot() throws Exception | ||
{ | ||
String num = "+.555555555555555555555555555555"; | ||
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class); | ||
assertEquals(new BigDecimal(num), w.number); | ||
} | ||
} |