forked from FasterXML/jackson-jr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Use Big Decimal for Tree (FasterXML#135)
- Loading branch information
Showing
6 changed files
with
74 additions
and
33 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
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
48 changes: 48 additions & 0 deletions
48
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/ReadAsBigDecimal90Test.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,48 @@ | ||
package com.fasterxml.jackson.jr.stree; | ||
|
||
import com.fasterxml.jackson.core.TreeNode; | ||
import com.fasterxml.jackson.jr.ob.JSON; | ||
|
||
import java.math.BigDecimal; | ||
|
||
// [jackson-jr#90]: JSON.Feature.USE_BIG_DECIMAL_FOR_FLOATS should work | ||
public class ReadAsBigDecimal90Test extends JacksonJrTreeTestBase | ||
{ | ||
// [jackson-jr#90] | ||
public void testDefaultBehaviourReadAsDouble() throws Exception | ||
{ | ||
JSON json = JSON.builder() | ||
.disable(JSON.Feature.USE_BIG_DECIMAL_FOR_FLOATS) | ||
.register(new JrSimpleTreeExtension()) | ||
.build(); | ||
|
||
String input = "[1.1]"; | ||
|
||
TreeNode node = json.treeFrom(input); | ||
TreeNode elemNode = node.get(0); | ||
|
||
assertTrue(elemNode.isValueNode()); | ||
assertTrue(elemNode instanceof JrsNumber); | ||
assertEquals(Double.class, | ||
((JrsNumber) elemNode).getValue().getClass()); | ||
} | ||
|
||
// [jackson-jr#90] | ||
public void testReadAsBigDecimal() throws Exception | ||
{ | ||
JSON json = JSON.builder() | ||
.enable(JSON.Feature.USE_BIG_DECIMAL_FOR_FLOATS) | ||
.register(new JrSimpleTreeExtension()) | ||
.build(); | ||
|
||
String input = "[1.1]"; | ||
|
||
TreeNode node = json.treeFrom(input); | ||
TreeNode elemNode = node.get(0); | ||
|
||
assertTrue(elemNode.isValueNode()); | ||
assertTrue(elemNode instanceof JrsNumber); | ||
assertEquals(BigDecimal.class, | ||
((JrsNumber) elemNode).getValue().getClass()); | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/ReadAsBigDecimal90Test.java
This file was deleted.
Oops, something went wrong.
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
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