Skip to content

Commit 5ca5907

Browse files
committed
Add a failing test for #1770
1 parent 5ed8707 commit 5ca5907

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/test/java/com/fasterxml/jackson/failing/Core384Test.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ public void testHierarchy() throws IOException {
1919

2020
Fleet fleet = initVehicle();
2121

22+
/*
2223
for (Vehicle v : fleet.vehicles) {
2324
System.out.println("Vehicle, type: "+v.getClass());
2425
}
26+
*/
2527
String serializedFleet = mapper
2628
.writerWithDefaultPrettyPrinter()
2729
.writeValueAsString(fleet);
2830

29-
System.out.println(serializedFleet);
31+
//System.out.println(serializedFleet);
3032

3133
Fleet deserializedFleet = mapper.readValue(serializedFleet, Fleet.class);
3234

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.databind.*;
4+
5+
/**
6+
* Basic tests for {@link JsonNode} implementations that
7+
* contain numeric values.
8+
*/
9+
public class NumberNodes1770Test extends BaseMapTest
10+
{
11+
private final ObjectMapper MAPPER = newObjectMapper();
12+
13+
// Related to [databind#1770]
14+
public void testBigDecimalCoercion() throws Exception
15+
{
16+
final JsonNode jsonNode = MAPPER.reader()
17+
.with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
18+
.readTree("7976931348623157e309");
19+
assertTrue(jsonNode.isBigDecimal());
20+
// the following fails with NumberFormatException, because jsonNode is a DoubleNode with a value of POSITIVE_INFINITY
21+
// Assert.assertTrue(jsonNode.decimalValue().compareTo(new BigDecimal("7976931348623157e309")) == 0);
22+
}
23+
}

0 commit comments

Comments
 (0)