Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add number test where num starts with a dot #4436

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,12 @@

public class TestBigNumbers extends BaseMapTest
{
static class BigDecimalWrapper {
BigDecimal number;

public BigDecimalWrapper() {}

public BigDecimalWrapper(BigDecimal number) {
this.number = number;
}

public void setNumber(BigDecimal number) {
this.number = number;
}
}

static class BigIntegerWrapper {
BigInteger number;

public BigIntegerWrapper() {}

public BigIntegerWrapper(BigInteger number) {
this.number = number;
}
public BigInteger number;
}

public void setNumber(BigInteger number) {
this.number = number;
}
static class BigDecimalWrapper {
public BigDecimal number;
}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.fasterxml.jackson.databind.deser.jdk;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import org.junit.jupiter.api.Test;

import java.math.BigDecimal;

import static org.junit.jupiter.api.Assertions.assertEquals;

// @since 2.16.3
public class BigDecimalDeser4435Test
{
static class BigDecimalWrapper {
public BigDecimal number;
}

/*
/**********************************************************
/* Tests
/**********************************************************
*/

private final ObjectMapper MAPPER = JsonMapper.builder().build();

@Test
public void testNumberStartingWithDot() throws Exception
{
String num = ".555555555555555555555555555555";
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
assertEquals(new BigDecimal(num), w.number);
}

@Test
public void testNumberStartingWithMinusDot() throws Exception
{
String num = "-.555555555555555555555555555555";
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
assertEquals(new BigDecimal(num), w.number);
}

@Test
public void testNumberStartingWithPlusDot() throws Exception
{
String num = "+.555555555555555555555555555555";
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
assertEquals(new BigDecimal(num), w.number);
}
}
Loading