mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
95561c1410
commit
3746c6048f
@ -66,8 +66,8 @@ public class BitSetBloomFilter implements BloomFilter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
int[] positions = createHashes(str, hashFunctionNumber);
|
int[] positions = createHashes(str, hashFunctionNumber);
|
||||||
for (int i = 0; i < positions.length; i++) {
|
for (int value : positions) {
|
||||||
int position = Math.abs(positions[i] % bitSetSize);
|
int position = Math.abs(value % bitSetSize);
|
||||||
bitSet.set(position, true);
|
bitSet.set(position, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
package cn.hutool.core.collection;
|
package cn.hutool.core.collection;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.comparator.PinyinComparator;
|
import cn.hutool.core.comparator.PinyinComparator;
|
||||||
import cn.hutool.core.comparator.PropertyComparator;
|
import cn.hutool.core.comparator.PropertyComparator;
|
||||||
@ -27,6 +19,35 @@ import cn.hutool.core.util.ReflectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.core.util.TypeUtil;
|
import cn.hutool.core.util.TypeUtil;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.AbstractCollection;
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Deque;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Stack;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 集合相关工具类
|
* 集合相关工具类
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -521,6 +521,7 @@ public class Convert {
|
|||||||
* @param defaultValue 默认值
|
* @param defaultValue 默认值
|
||||||
* @return Enum
|
* @return Enum
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
|
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
|
||||||
return (E) (new EnumConverter(clazz)).convertQuietly(value, defaultValue);
|
return (E) (new EnumConverter(clazz)).convertQuietly(value, defaultValue);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,9 @@ import cn.hutool.crypto.symmetric.DES;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DES加密解密单元测试
|
||||||
|
*/
|
||||||
public class DesTest {
|
public class DesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package cn.hutool.json;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题反馈解析为null<br>
|
||||||
|
* 此问题出在用户定义了String类型的List,parseArray时,Hutool无法知道这个String是普通值还是JSON字符串<br>
|
||||||
|
* 就算知道也不能盲目解析,否则可能违背用户的初衷。<br>
|
||||||
|
* 因此遇到List中的元素是String的情况下,用户需手动单独parse。
|
||||||
|
*/
|
||||||
|
public class IssueI1AU86Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toListTest() {
|
||||||
|
List<String> redisList = CollUtil.newArrayList(
|
||||||
|
"{\"updateDate\":1583376342000,\"code\":\"move\",\"id\":1,\"sort\":1,\"name\":\"电影大全\"}",
|
||||||
|
"{\"updateDate\":1583378882000,\"code\":\"zy\",\"id\":3,\"sort\":5,\"name\":\"综艺会\"}"
|
||||||
|
);
|
||||||
|
|
||||||
|
// 手动parse
|
||||||
|
final JSONArray jsonArray = new JSONArray();
|
||||||
|
for (String str : redisList) {
|
||||||
|
jsonArray.add(JSONUtil.parse(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Vcc> vccs = jsonArray.toList(Vcc.class);
|
||||||
|
for (Vcc vcc : vccs) {
|
||||||
|
Assert.assertNotNull(vcc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Vcc implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private Long id;
|
||||||
|
private Date updateDate;
|
||||||
|
private String code;
|
||||||
|
private String name;
|
||||||
|
private Integer sort;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user