diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestBigNumbers.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestBigNumbers.java index 3050e1a011..78af809158 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/TestBigNumbers.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestBigNumbers.java @@ -13,32 +13,12 @@ public class TestBigNumbers extends BaseMapTest { - static class BigDecimalWrapper { - BigDecimal number; - - public BigDecimalWrapper() {} - - public BigDecimalWrapper(BigDecimal number) { - this.number = number; - } - - public void setNumber(BigDecimal number) { - this.number = number; - } - } - static class BigIntegerWrapper { - BigInteger number; - - public BigIntegerWrapper() {} - - public BigIntegerWrapper(BigInteger number) { - this.number = number; - } + public BigInteger number; + } - public void setNumber(BigInteger number) { - this.number = number; - } + static class BigDecimalWrapper { + public BigDecimal number; } /* diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigDecimalDeser4435Test.java b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigDecimalDeser4435Test.java new file mode 100644 index 0000000000..5ac825a5b7 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigDecimalDeser4435Test.java @@ -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); + } +}