diff options
author | Tiago Martins <tiagomartins282@gmail.com> | 2020-07-23 22:44:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-23 14:44:26 -0700 |
commit | 942aa25950eed2fa297c600c7d15b0b02f6fd8d7 (patch) | |
tree | c877f6cf16a27e66d470f006f9887b9eb9325ce2 /src/test | |
parent | 461cd4db9bf02691b1e546dc1d23794501d8cc74 (diff) | |
download | jackson-databind-942aa25950eed2fa297c600c7d15b0b02f6fd8d7.tar.gz |
Support BigInteger and BigDecimal in StdValueInstantiator (#2793)
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java | 18 | ||||
-rw-r--r-- | src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCreators.java | 14 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java b/src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java index 13aca9c95..8e1925494 100644 --- a/src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java @@ -1,6 +1,8 @@ package com.fasterxml.jackson.databind; import java.io.*; +import java.math.BigDecimal; +import java.math.BigInteger; import java.util.*; import static org.junit.Assert.*; @@ -58,12 +60,28 @@ public abstract class BaseMapTest public LongWrapper(long value) { l = value; } } + protected static class BigIntegerWrapper { + public BigInteger i; + + public BigIntegerWrapper() { } + + public BigIntegerWrapper(final BigInteger value) { i = value; } + } + protected static class DoubleWrapper { public double d; public DoubleWrapper() { } public DoubleWrapper(double value) { d = value; } } + + protected static class BigDecimalWrapper { + public BigDecimal d; + + public BigDecimalWrapper() { } + + public BigDecimalWrapper(final BigDecimal value) { d = value; } + } /** * Simple wrapper around String type, usually to test value diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCreators.java b/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCreators.java index 5b6247855..7c8e389d8 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCreators.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCreators.java @@ -1,5 +1,7 @@ package com.fasterxml.jackson.databind.deser.creators; +import java.math.BigDecimal; +import java.math.BigInteger; import java.util.*; import com.fasterxml.jackson.annotation.*; @@ -329,6 +331,18 @@ public class TestCreators assertTrue(bean2.b); } + public void testSimpleBigIntegerConstructor() throws Exception + { + final BigIntegerWrapper result = MAPPER.readValue("17", BigIntegerWrapper.class); + assertEquals(new BigInteger("17"), result.i); + } + + public void testSimpleBigDecimalConstructor() throws Exception + { + final BigDecimalWrapper result = MAPPER.readValue("42.5", BigDecimalWrapper.class); + assertEquals(new BigDecimal("42.5"), result.d); + } + public void testSimpleFactory() throws Exception { FactoryBean bean = MAPPER.readValue("{ \"f\" : 0.25 }", FactoryBean.class); |