package com.alibaba.fastjson2.issues_2700;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.junit.jupiter.api.Test;

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

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

public class Issue2745 {
    @Test
    public void Test1() throws Exception {
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(true);
        assertEquals(BigDecimal.ONE, jsonArray.getBigDecimal(0));
        assertEquals(BigInteger.ONE, jsonArray.getBigInteger(0));
        assertEquals(Integer.valueOf(1), jsonArray.getInteger(0));
        assertEquals(Long.valueOf(1), jsonArray.getLong(0));
    }

    @Test
    public void Test2() throws Exception {
        JSONObject obj = new JSONObject();
        obj.put("bool", true);
        assertEquals(BigDecimal.ONE, obj.getBigDecimal("bool"));
        assertEquals(BigInteger.ONE, obj.getBigInteger("bool"));
        assertEquals(Integer.valueOf(1), obj.getInteger("bool"));
        assertEquals(Long.valueOf(1), obj.getLong("bool"));
    }
}
