add testcase

This commit is contained in:
高铁
2016-04-27 13:47:53 +08:00
parent 44bb8de77d
commit 00f4638b5b
2 changed files with 42 additions and 2 deletions
@@ -0,0 +1,40 @@
package com.alibaba.json.bvt.parser;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
public class BigListStringFieldTest extends TestCase {
public void test_list() throws Exception {
Model model = new Model();
model.values = new ArrayList<String>(10000);
for (int i = 0; i < 10000; ++i) {
String value = random(100);
model.values.add(value);
}
String text = JSON.toJSONString(model);
Model model2 = JSON.parseObject(text, Model.class);
Assert.assertEquals(model.values, model2.values);
}
public static class Model {
public List<String> values;
}
public String random(int count) {
Random random = new Random();
char[] chars = new char[count];
for (int i = 0; i < count; ++i) {
chars[i] = (char) random.nextInt();
}
return new String(chars);
}
}
@@ -23,10 +23,10 @@ public class BenchmarkMain {
executor.setLoopCount(1000 * 100);
// executor.getCaseList().add(new CartObjectParse());
// executor.getCaseList().add(new TradeParse());
executor.getCaseList().add(new TradeParse());
// executor.getCaseList().add(new XueluDecode());
// executor.getCaseList().add(new EishayEncode());
executor.getCaseList().add(new EishayDecode());
// executor.getCaseList().add(new EishayDecode());
// executor.getCaseList().add(new GetHomePageResponseDecode());
// executor.getCaseList().add(new EishayTreeDecode());
// executor.getCaseList().add(new Eishay3Encode());