Skip to content

Commit

Permalink
Add a failing test for #1770
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 21, 2017
1 parent 5ed8707 commit 5ca5907
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/test/java/com/fasterxml/jackson/failing/Core384Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ public void testHierarchy() throws IOException {

Fleet fleet = initVehicle();

/*
for (Vehicle v : fleet.vehicles) {
System.out.println("Vehicle, type: "+v.getClass());
}
*/
String serializedFleet = mapper
.writerWithDefaultPrettyPrinter()
.writeValueAsString(fleet);

System.out.println(serializedFleet);
//System.out.println(serializedFleet);

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.databind.*;

/**
* Basic tests for {@link JsonNode} implementations that
* contain numeric values.
*/
public class NumberNodes1770Test extends BaseMapTest
{
private final ObjectMapper MAPPER = newObjectMapper();

// Related to [databind#1770]
public void testBigDecimalCoercion() throws Exception
{
final JsonNode jsonNode = MAPPER.reader()
.with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
.readTree("7976931348623157e309");
assertTrue(jsonNode.isBigDecimal());
// the following fails with NumberFormatException, because jsonNode is a DoubleNode with a value of POSITIVE_INFINITY
// Assert.assertTrue(jsonNode.decimalValue().compareTo(new BigDecimal("7976931348623157e309")) == 0);
}
}

0 comments on commit 5ca5907

Please sign in to comment.