mirror of https://github.com/alibaba/fastjson2.git
add testcase
This commit is contained in:
parent
9c08f49ea0
commit
395c52440b
|
|
@ -23,6 +23,11 @@ public class NonDefaulConstructorTest {
|
|||
assertEquals(1001, vo.id);
|
||||
assertEquals("bill", vo.name);
|
||||
}
|
||||
{
|
||||
VO vo = objectReader.readObject(JSONReader.of("{'id':1001,'name':'bill'}"), 0);
|
||||
assertEquals(1001, vo.id);
|
||||
assertEquals("bill", vo.name);
|
||||
}
|
||||
{
|
||||
Map map = new LinkedHashMap<>();
|
||||
map.put("id", 1001);
|
||||
|
|
@ -35,6 +40,22 @@ public class NonDefaulConstructorTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuild_1() throws Exception {
|
||||
{
|
||||
String str = "{\"id\":1001,\"name\":\"bill\"}";
|
||||
VO vo = JSON.parseObject(str, VO.class);
|
||||
assertEquals(1001, vo.id);
|
||||
assertEquals("bill", vo.name);
|
||||
}
|
||||
{
|
||||
String str = "{'id':1001,'name':'bill'}";
|
||||
VO vo = JSON.parseObject(str, VO.class);
|
||||
assertEquals(1001, vo.id);
|
||||
assertEquals("bill", vo.name);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuild_2() throws Exception {
|
||||
String str = JSONObject
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.alibaba.fastjson2.codec;
|
|||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONB;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -35,6 +36,13 @@ public class NonDefaulConstructorTestTest2 {
|
|||
assertEquals(3, a.id);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_ab_1() {
|
||||
String str = JSONObject.of("id", 3).fluentPut("name", "DataWorks").toString(JSONWriter.Feature.UseSingleQuotes);
|
||||
B a = JSON.parseObject(str, B.class);
|
||||
assertEquals(3, a.id);
|
||||
}
|
||||
|
||||
public static class A {
|
||||
private BigDecimal amount;
|
||||
private Currency currency;
|
||||
|
|
|
|||
Loading…
Reference in New Issue