mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-21 08:46:33 +08:00
add testcase
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user