add testcase

This commit is contained in:
wenshao
2012-07-13 08:21:33 +08:00
parent 88c8864c94
commit e331ffb6ec
@@ -1,7 +1,9 @@
package com.alibaba.json.bvt.bug;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import junit.framework.Assert;
import junit.framework.TestCase;
@@ -14,15 +16,19 @@ public class Bug_for_80108116 extends TestCase {
public void test_for_dateFormat() throws Exception {
VO vo = new VO();
vo.setDate(new SimpleDateFormat("yyyy-MM-dd").parse("2012-07-12"));
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"date\":\"2012-07-12\"}", text);
List<VO> voList = new ArrayList<VO>();
voList.add(vo);
String text = JSON.toJSONString(voList);
Assert.assertEquals("[{\"date\":\"2012-07-12\"}]", text);
}
public static class VO {
@JSONField(format = "yyyy-MM-dd")
private Date date;
@JSONField(format = "yyyy-MM-dd")
public Date getDate() {
return date;
}
@@ -31,4 +37,5 @@ public class Bug_for_80108116 extends TestCase {
this.date = date;
}
}
}