Skip to content

Commit

Permalink
E Notation Number tests (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Apr 9, 2023
1 parent 099f91a commit 194378f
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fasterxml.jackson.dataformat.xml.deser;

import java.math.BigDecimal;
import java.math.BigInteger;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
Expand All @@ -24,6 +25,14 @@ public void testNumbers() throws Exception
_testScalar(BigInteger.valueOf(31337), "<BigInteger>31337</BigInteger>");
}

public void testNumbersWithENotation() throws Exception
{
BigInteger bigInteger = new BigDecimal("2e308").toBigInteger();
_testScalar(bigInteger, "<BigInteger>" + bigInteger + "</BigInteger>");
BigDecimal bigDecimal = new BigDecimal("2e308");
_testScalar(bigDecimal, "<BigDecimal>" + bigDecimal + "</BigDecimal>");
}

private void _testScalar(Object input, String exp) throws Exception {
_testScalar(input, input.getClass(), exp);
}
Expand All @@ -32,7 +41,7 @@ private void _testScalar(Object input, Class<?> type, String exp) throws Excepti
{
String xml = MAPPER.writeValueAsString(input).trim();
assertEquals(exp, xml);
Object result = MAPPER.readValue(xml, input.getClass());
Object result = MAPPER.readValue(xml, type);
assertEquals(input, result);
}
}

0 comments on commit 194378f

Please sign in to comment.