fix StrUtil bug

This commit is contained in:
Looly
2020-09-15 01:00:26 +08:00
parent ddd173a17c
commit d205225cef
5 changed files with 85 additions and 78 deletions

View File

@@ -5,12 +5,23 @@ import org.junit.Assert;
import org.junit.Test;
public class Issue1075Test {
@Test
public void test() {
String s = "{\"f1\":\"f1\",\"F2\":\"f2\",\"fac\":\"fac\"}";
ObjA o2 = JSONUtil.parseObj(s, JSONConfig.create().setIgnoreCase(true)).toBean(ObjA.class);
final String jsonStr = "{\"f1\":\"f1\",\"f2\":\"f2\",\"fac\":\"fac\"}";
@Test
public void testToBean() {
// 在不忽略大小写的情况下f2、fac都不匹配
ObjA o2 = JSONUtil.toBean(jsonStr, ObjA.class);
Assert.assertNull(o2.getFAC());
Assert.assertNull(o2.getF2());
}
@Test
public void testToBeanIgnoreCase() {
// 在忽略大小写的情况下f2、fac都匹配
ObjA o2 = JSONUtil.parseObj(jsonStr, JSONConfig.create().setIgnoreCase(true)).toBean(ObjA.class);
Assert.assertEquals("fac", o2.getFAC());
Assert.assertEquals("f2", o2.getF2());
}
@Data