mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix test
This commit is contained in:
@@ -216,8 +216,6 @@ public class UrlQueryUtil {
|
||||
return MapUtil.empty();
|
||||
}
|
||||
|
||||
Console.log(queryMap);
|
||||
|
||||
final Map<String, List<String>> params = new LinkedHashMap<>();
|
||||
queryMap.forEach((key, value) -> {
|
||||
if(null != key){
|
||||
|
@@ -23,6 +23,7 @@ import lombok.Setter;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
@@ -79,6 +80,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
final List<Integer> list = asList(1, 2, 3);
|
||||
final Map<String, Integer> identityMap = wrap(list).toMap(String::valueOf);
|
||||
Assertions.assertEquals(new HashMap<String, Integer>() {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
@@ -103,6 +105,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
final List<String> list = asList("bugotech", "hutool", "sweet");
|
||||
final Map<Integer, String> toZip = wrap(orders).toZip(list);
|
||||
Assertions.assertEquals(new HashMap<Integer, String>() {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
@@ -169,6 +172,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
public void testGrouping() {
|
||||
final List<Integer> list = asList(1, 2, 3);
|
||||
final Map<String, List<Integer>> map = new HashMap<String, List<Integer>>() {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
@@ -190,6 +194,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
public void testPartitioning() {
|
||||
final List<Integer> list = asList(1, 2, 3);
|
||||
final Map<Boolean, List<Integer>> map = new HashMap<Boolean, List<Integer>>() {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
@@ -632,6 +637,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
@Test
|
||||
public void testToEntries() {
|
||||
final Map<Integer, Integer> expect = new HashMap<Integer, Integer>() {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
@@ -730,7 +736,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
void test() {
|
||||
final List<List<List<String>>> list = Arrays.asList(
|
||||
Arrays.asList(
|
||||
Arrays.asList("a"),
|
||||
List.of("a"),
|
||||
Arrays.asList("b", "c"),
|
||||
Arrays.asList("d", "e", "f")
|
||||
),
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package cn.hutool.v7.core.text.finder;
|
||||
|
||||
import cn.hutool.v7.core.lang.Console;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -24,43 +26,34 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author cmm
|
||||
* @date 2024/8/12 11:16
|
||||
*/
|
||||
public class MultiStrFinderTest {
|
||||
|
||||
@Test
|
||||
public void test1(){
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
final ArrayList<String> strings = new ArrayList<>();
|
||||
strings.add("sha");
|
||||
strings.add("asa");
|
||||
strings.add("ha");
|
||||
strings.add("hex");
|
||||
MultiStrFinder finder = MultiStrFinder.of(strings);
|
||||
String text = "asdasahhxxeshaaahexaaasa";
|
||||
Map<String, List<Integer>> match = finder.findMatch(text);
|
||||
System.out.println(text);
|
||||
match.forEach((k,v) -> {
|
||||
System.out.println(k + ":" + v);
|
||||
});
|
||||
|
||||
final MultiStrFinder finder = MultiStrFinder.of(strings);
|
||||
final String text = "asdasahhxxeshaaahexaaasa";
|
||||
final Map<String, List<Integer>> match = finder.findMatch(text);
|
||||
Assertions.assertEquals(3, match.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test2(){
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
final ArrayList<String> strings = new ArrayList<>();
|
||||
strings.add("沙漠");
|
||||
strings.add("撒");
|
||||
strings.add("哈");
|
||||
strings.add("害克斯");
|
||||
MultiStrFinder finder = MultiStrFinder.of(strings);
|
||||
String text = "撒哈拉大沙漠,你看哈哈哈。hex码中文写成海克斯科技";
|
||||
Map<String, List<Integer>> match = finder.findMatch(text);
|
||||
System.out.println(text);
|
||||
match.forEach((k,v) -> {
|
||||
System.out.println(k + ":" + v);
|
||||
});
|
||||
|
||||
final MultiStrFinder finder = MultiStrFinder.of(strings);
|
||||
final String text = "撒哈拉大沙漠,你看哈哈哈。hex码中文写成海克斯科技";
|
||||
final Map<String, List<Integer>> match = finder.findMatch(text);
|
||||
Assertions.assertEquals(3, match.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,13 +16,10 @@
|
||||
|
||||
package cn.hutool.v7.core.text.replacer;
|
||||
|
||||
import cn.hutool.v7.core.text.finder.MultiStrFinder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author cmm
|
||||
@@ -31,37 +28,34 @@ import java.util.Map;
|
||||
public class HighMultiReplacerV2Test {
|
||||
@Test
|
||||
public void test1(){
|
||||
HashMap<String, String> replaceMap = new HashMap<>();
|
||||
final HashMap<String, String> replaceMap = new HashMap<>();
|
||||
replaceMap.put("sha","SHA");
|
||||
replaceMap.put("asa","ASA");
|
||||
replaceMap.put("ha","HA");
|
||||
replaceMap.put("hex","HEX");
|
||||
HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap);
|
||||
String text = "asdasahhxxeshaaahexaaasa";
|
||||
CharSequence apply = replacer.apply(text);
|
||||
replaceMap.forEach((k,v) -> {
|
||||
System.out.println(k + ":" + v);
|
||||
});
|
||||
System.out.println(text);
|
||||
System.out.println(apply);
|
||||
final HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap);
|
||||
final String text = "asdasahhxxeshaaahexaaasa";
|
||||
final CharSequence apply = replacer.apply(text);
|
||||
// replaceMap.forEach((k,v) -> {
|
||||
// System.out.println(k + ":" + v);
|
||||
// });
|
||||
Assertions.assertEquals("asdASAhhxxeSHAaaHEXaaASA", apply.toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test2(){
|
||||
HashMap<String, String> replaceMap = new HashMap<>();
|
||||
final HashMap<String, String> replaceMap = new HashMap<>();
|
||||
replaceMap.put("沙漠","什么");
|
||||
replaceMap.put("撒","厦");
|
||||
replaceMap.put("哈","蛤");
|
||||
replaceMap.put("海克斯","害可是");
|
||||
HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap);
|
||||
String text = "撒哈拉大沙漠,你看哈哈哈。hex码中文写成海克斯科技,海克,沙子收拾收拾,撤退,撒下了句点";
|
||||
CharSequence apply = replacer.apply(text);
|
||||
replaceMap.forEach((k,v) -> {
|
||||
System.out.println(k + ":" + v);
|
||||
});
|
||||
System.out.println(text);
|
||||
System.out.println(apply);
|
||||
|
||||
final HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap);
|
||||
final String text = "撒哈拉大沙漠,你看哈哈哈。hex码中文写成海克斯科技,海克,沙子收拾收拾,撤退,撒下了句点";
|
||||
final CharSequence apply = replacer.apply(text);
|
||||
// replaceMap.forEach((k,v) -> {
|
||||
// System.out.println(k + ":" + v);
|
||||
// });
|
||||
Assertions.assertEquals("厦蛤拉大什么,你看蛤蛤蛤。hex码中文写成害可是科技,海克,沙子收拾收拾,撤退,厦下了句点", apply.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -16,10 +16,9 @@
|
||||
|
||||
package cn.hutool.v7.core.tree;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.v7.core.collection.ListUtil;
|
||||
import cn.hutool.v7.core.lang.Console;
|
||||
import cn.hutool.v7.core.tree.parser.DefaultNodeParser;
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -84,7 +83,7 @@ public class TreeTest {
|
||||
tree.putExtra("other", new Object());
|
||||
});
|
||||
|
||||
Assertions.assertEquals(treeNodes.size(), 2);
|
||||
Assertions.assertEquals(2, treeNodes.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,7 +99,7 @@ public class TreeTest {
|
||||
public void walkBroadFirstTest() {
|
||||
final List<String> ids = new ArrayList<>();
|
||||
final MapTree<String> tree = TreeUtil.buildSingle(nodeList, "0");
|
||||
Console.log(tree);
|
||||
//Console.log(tree);
|
||||
tree.walk((tr) -> ids.add(tr.getId()), true);
|
||||
|
||||
Assertions.assertEquals(7, ids.size());
|
||||
@@ -166,11 +165,11 @@ public class TreeTest {
|
||||
treeNodeConfig.setDeep(3);
|
||||
|
||||
final List<MapTree<String>> treeNodes = TreeUtil.build(nodeList, "0", treeNodeConfig, new DefaultNodeParser<>());
|
||||
Assertions.assertEquals(treeNodes.size(), 2);
|
||||
Assertions.assertEquals(2, treeNodes.size());
|
||||
final MapTree<String> treeNode1 = treeNodes.get(1);
|
||||
Assertions.assertNotNull(treeNode1);
|
||||
Assertions.assertNotNull(treeNode1.getConfig());
|
||||
Assertions.assertEquals(treeNode1.getChildren().size(), 1);
|
||||
Assertions.assertEquals(1, treeNode1.getChildren().size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user