package com.alibaba.fastjson2.issues_2300;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import org.junit.jupiter.api.Test;

import java.math.BigInteger;

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

public class Issue2305 {
    BigInteger bigInt = new BigInteger("18446744073709550616");
    String s = "{\"value\": " + bigInt + "}";

    @Test
    public void test() {
        Bean bean = JSON.parseObject(s, Bean.class, JSONReader.Feature.NonErrorOnNumberOverflow);
        assertEquals(bean.value, bigInt.longValue());
    }

    public static class Bean {
        public long value;
    }

    @Test
    public void testInt() {
        Bean1 bean = JSON.parseObject(s, Bean1.class, JSONReader.Feature.NonErrorOnNumberOverflow);
        assertEquals(bean.value, bigInt.intValue());
    }

    public static class Bean1 {
        public int value;
    }
}
