package com.alibaba.json.bvt.serializer.features;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.junit.Assert;

import java.math.BigDecimal;

/**
 * Created by wenshao on 16/8/9.
 */
public class WriteBigDecimalAsPlainTest extends TestCase {
    public void test_for_feature() throws Exception {
        BigDecimal value = new BigDecimal("0.00000001");

        Assert.assertEquals("1E-8", JSON.toJSONString(value));
        Assert.assertEquals("0.00000001", JSON.toJSONString(value, SerializerFeature.WriteBigDecimalAsPlain));
    }

    public void test_1() throws Exception {
        Model m = new Model();
        m.value = new BigDecimal("0.00000001");

        Assert.assertEquals("{\"value\":1E-8}", JSON.toJSONString(m));
        Assert.assertEquals("{\"value\":0.00000001}", JSON.toJSONString(m, SerializerFeature.WriteBigDecimalAsPlain));
    }

    public static class Model {
        private BigDecimal value;

        public BigDecimal getValue() {
            return value;
        }

        public void setValue(BigDecimal value) {
            this.value = value;
        }
    }
}

@@ -223,16 +223,45 @@
 Decimal;
+%0Aimport java.math.BigInteger;
 %0A%0A/**%0A *
@@ -983,179 +983,794 @@
 lic 
-static class Model %7B%0A        private BigDecimal value;%0A%0A        public BigDecimal getValue() %7B%0A            return value;%0A        %7D%0A%0A        public void setValue(BigDecimal
+void test_for_feature_BigInteger() throws Exception %7B%0A        BigInteger value = new BigInteger(%222020020700826004000000000000%22);%0A%0A        Assert.assertEquals(%222020020700826004000000000000%22, JSON.toJSONString(value));%0A        Assert.assertEquals(%222020020700826004000000000000%22, JSON.toJSONString(value, SerializerFeature.WriteBigDecimalAsPlain));%0A    %7D%0A%0A    public static class Model %7B%0A        private BigDecimal value;%0A%0A        public BigDecimal getValue() %7B%0A            return value;%0A        %7D%0A%0A        public void setValue(BigDecimal value) %7B%0A            this.value = value;%0A        %7D%0A    %7D%0A%0A    public static class ModelBigInteger %7B%0A        private BigInteger value;%0A%0A        public BigInteger getValue() %7B%0A            return value;%0A        %7D%0A%0A        public void setValue(BigInteger
  val

add testcase