package net.minidev.json.test;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;

import net.minidev.json.JSONObject;
import net.minidev.json.JSONValue;
import junit.framework.TestCase;

public class TestBigValue extends TestCase {
	String bigStr = "12345678901234567890123456789";

	/**
	 * test BigDecimal serialization
	 */
	public void testBigDecimal() {
		HashMap<String, Object> map = new HashMap<String, Object>();
		BigDecimal bigDec = new BigDecimal(bigStr + "." + bigStr);
		map.put("big", bigDec);
		String test = JSONValue.toJSONString(map);
		String result = "{\"big\":" + bigStr + "." +bigStr + "}";
		assertEquals(result, test);
		JSONObject obj =  (JSONObject)JSONValue.parse(test);
		assertEquals(bigDec, obj.get("big"));
		assertEquals(bigDec.getClass(), obj.get("big").getClass());
	}

	/**
	 * test BigInteger serialization
	 */
	public void testBigInteger() {
		HashMap<String, Object> map = new HashMap<String, Object>();
		BigInteger bigInt = new BigInteger(bigStr);
		map.put("big", bigInt);
		String test = JSONValue.toJSONString(map);
		String result = "{\"big\":" + bigStr + "}";
		assertEquals(result, test);
		JSONObject obj =  (JSONObject)JSONValue.parse(test);
		assertEquals(bigInt, obj.get("big"));
		assertEquals(bigInt.getClass(), obj.get("big").getClass());
	}
}

@@ -1325,10 +1325,467 @@
 ());%0A%09%7D%0A
+%09/**%0A%09 * https://github.com/netplex/json-smart-v1/issues/6%0A%09 */%0A%09@Test%0A    public void testBigDouble() throws Exception %7B%0A        String content = %22%7B%5C%22customDouble%5C%22: 3.14159265358979323846%7D%22;%0A        System.out.printf(%22Input: %25s%5Cn%22, content);%0A        JSONParser parser = new JSONParser(DEFAULT_PERMISSIVE_MODE);%0A        JSONObject jwtContent = (JSONObject) parser.parse(content);%0A        System.out.printf(%22Output: %25s%5Cn%22, jwtContent.toJSONString());%0A    %7D%0A
 %7D%0A

add test from issue 6