mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
34
hutool-json/src/test/java/cn/hutool/json/IssueI6LBZATest.java
Executable file
34
hutool-json/src/test/java/cn/hutool/json/IssueI6LBZATest.java
Executable file
@@ -0,0 +1,34 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IssueI6LBZATest {
|
||||
@Test
|
||||
public void parseJSONStringTest() {
|
||||
final String a = "\"a\"";
|
||||
final JSON parse = JSONUtil.parse(a);
|
||||
Assert.assertEquals(JSONString.class, parse.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseJSONStringTest2() {
|
||||
final String a = "'a'";
|
||||
final JSON parse = JSONUtil.parse(a);
|
||||
Assert.assertEquals(JSONString.class, parse.getClass());
|
||||
}
|
||||
|
||||
@Test(expected = JSONException.class)
|
||||
public void parseJSONErrorTest() {
|
||||
final String a = "a";
|
||||
final JSON parse = JSONUtil.parse(a);
|
||||
Assert.assertEquals(JSONString.class, parse.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseJSONNumberTest() {
|
||||
final String a = "123";
|
||||
final JSON parse = JSONUtil.parse(a);
|
||||
Assert.assertEquals(JSONNumber.class, parse.getClass());
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.math.NumberUtil;
|
||||
import cn.hutool.json.serialize.JSONString;
|
||||
import cn.hutool.json.serialize.JSONStringer;
|
||||
import cn.hutool.json.test.bean.Price;
|
||||
import cn.hutool.json.test.bean.UserA;
|
||||
import cn.hutool.json.test.bean.UserC;
|
||||
@@ -179,7 +179,7 @@ public class JSONUtilTest {
|
||||
@Test
|
||||
public void customValueTest() {
|
||||
final JSONObject jsonObject = JSONUtil.ofObj()
|
||||
.set("test2", (JSONString) () -> NumberUtil.format("#.0", 12.00D));
|
||||
.set("test2", (JSONStringer) () -> NumberUtil.format("#.0", 12.00D));
|
||||
|
||||
Assert.assertEquals("{\"test2\":12.0}", jsonObject.toString());
|
||||
}
|
||||
|
Reference in New Issue
Block a user