Skip to content

Commit

Permalink
Add failing test for #4694
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 11, 2024
1 parent eeb4fdd commit 8dda2f4
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.fasterxml.jackson.failing;

import java.math.BigDecimal;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.Assert.assertEquals;

public class BigDecimalParsing4694Test extends DatabindTestUtil
{
private final String BIG_DEC_STR;
{
StringBuilder sb = new StringBuilder("-1234.");
// Above 500 chars we get a problem:
for (int i = 520; --i >= 0; ) {
sb.append('0');
}
BIG_DEC_STR = sb.toString();
}

private final ObjectMapper MAPPER = newJsonMapper();

// [databind#4694]: decoded wrong by jackson-core/FDP for over 500 char numbers
@Test
public void bigDecimal4694FromString() throws Exception
{
assertEquals(new BigDecimal(BIG_DEC_STR),
MAPPER.readValue(BIG_DEC_STR, BigDecimal.class));
}

@Test
public void bigDecimal4694FromBytes() throws Exception
{
byte[] b = utf8Bytes(BIG_DEC_STR);
assertEquals(new BigDecimal(BIG_DEC_STR),
MAPPER.readValue(b, 0, b.length, BigDecimal.class));
}
}

0 comments on commit 8dda2f4

Please sign in to comment.