mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -25,7 +25,7 @@ public class LRUCacheTest {
|
||||
final LRUCache<String, String> cache = CacheUtil.newLRUCache(100, 10);
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
//ThreadUtil.execute(()-> cache.put(RandomUtil.randomString(5), "1243", 10));
|
||||
ThreadUtil.execute(()-> cache.get(RandomUtil.randomString(5), ()->RandomUtil.randomString(10)));
|
||||
ThreadUtil.execute(()-> cache.get(RandomUtil.randomStringLower(5), ()->RandomUtil.randomStringLower(10)));
|
||||
}
|
||||
ThreadUtil.sleep(3000);
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ public class Base32Test {
|
||||
|
||||
@Test
|
||||
public void encodeAndDecodeRandomTest(){
|
||||
final String a = RandomUtil.randomString(RandomUtil.randomInt(1000));
|
||||
final String a = RandomUtil.randomStringLower(RandomUtil.randomInt(1000));
|
||||
final String encode = Base32.encode(a);
|
||||
final String decodeStr = Base32.decodeStr(encode);
|
||||
Assertions.assertEquals(a, decodeStr);
|
||||
|
@@ -35,7 +35,7 @@ public class Base62Test {
|
||||
|
||||
@Test
|
||||
public void encodeAndDecodeRandomTest() {
|
||||
final String a = RandomUtil.randomString(RandomUtil.randomInt(1000));
|
||||
final String a = RandomUtil.randomStringLower(RandomUtil.randomInt(1000));
|
||||
final String encode = Base62.encode(a);
|
||||
final String decodeStr = Base62.decodeStr(encode);
|
||||
Assertions.assertEquals(a, decodeStr);
|
||||
@@ -43,7 +43,7 @@ public class Base62Test {
|
||||
|
||||
@Test
|
||||
public void encodeAndDecodeInvertedRandomTest() {
|
||||
final String a = RandomUtil.randomString(RandomUtil.randomInt(1000));
|
||||
final String a = RandomUtil.randomStringLower(RandomUtil.randomInt(1000));
|
||||
final String encode = Base62.encodeInverted(a);
|
||||
final String decodeStr = Base62.decodeStrInverted(encode);
|
||||
Assertions.assertEquals(a, decodeStr);
|
||||
|
@@ -17,7 +17,7 @@ public class Base64Test {
|
||||
|
||||
@Test
|
||||
public void isTypeBase64Test(){
|
||||
Assertions.assertTrue(Base64.isTypeBase64(Base64.encode(RandomUtil.randomString(1000))));
|
||||
Assertions.assertTrue(Base64.isTypeBase64(Base64.encode(RandomUtil.randomStringLower(1000))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -97,7 +97,7 @@ public class MetroHashTest {
|
||||
final String[] result = new String[10000000];
|
||||
int index = 0;
|
||||
while (index < 10000000) {
|
||||
result[index++] = RandomUtil.randomString(RandomUtil.randomInt(64));
|
||||
result[index++] = RandomUtil.randomStringLower(RandomUtil.randomInt(64));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -11,10 +11,10 @@ public class MemorySafeLinkedBlockingQueueTest {
|
||||
public void offerTest(){
|
||||
// 设置初始值达到最大,这样任何时候元素都无法加入队列
|
||||
final MemorySafeLinkedBlockingQueue<String> queue = new MemorySafeLinkedBlockingQueue<>(Long.MAX_VALUE);
|
||||
Assertions.assertFalse(queue.offer(RandomUtil.randomString(RandomUtil.randomInt(100))));
|
||||
Assertions.assertFalse(queue.offer(RandomUtil.randomStringLower(RandomUtil.randomInt(100))));
|
||||
|
||||
// 设定一个很小的值,可以成功加入
|
||||
queue.setMaxFreeMemory(10);
|
||||
Assertions.assertTrue(queue.offer(RandomUtil.randomString(RandomUtil.randomInt(100))));
|
||||
Assertions.assertTrue(queue.offer(RandomUtil.randomStringLower(RandomUtil.randomInt(100))));
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ package org.dromara.hutool.core.func;
|
||||
import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.date.DateUtil;
|
||||
import org.dromara.hutool.core.date.StopWatch;
|
||||
import org.dromara.hutool.core.func.FunctionPool;
|
||||
import org.dromara.hutool.core.util.RandomUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -31,7 +30,7 @@ public class FunctionPoolTest {
|
||||
// 测试数据
|
||||
final ArrayList<char[]> list = ListUtil.of();
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
list.add(RandomUtil.randomString(100).toCharArray());
|
||||
list.add(RandomUtil.randomStringLower(100).toCharArray());
|
||||
}
|
||||
|
||||
final StopWatch stopWatch = DateUtil.createStopWatch();
|
||||
|
@@ -13,7 +13,7 @@ public class InternUtilTest {
|
||||
@Test
|
||||
public void weakTest(){
|
||||
final Intern<String> intern = InternUtil.ofWeak();
|
||||
final String a1 = RandomUtil.randomString(RandomUtil.randomInt(100));
|
||||
final String a1 = RandomUtil.randomStringLower(RandomUtil.randomInt(100));
|
||||
final String a2 = new String(a1);
|
||||
|
||||
Assertions.assertNotSame(a1, a2);
|
||||
|
@@ -39,6 +39,6 @@ public class TolerantMapTest {
|
||||
map.put("tuesday", "星期二");
|
||||
|
||||
assert "星期二".equals(map.get("tuesday"));
|
||||
assert "default".equals(map.get(RandomUtil.randomString(6)));
|
||||
assert "default".equals(map.get(RandomUtil.randomStringLower(6)));
|
||||
}
|
||||
}
|
||||
|
@@ -461,7 +461,7 @@ public class StrUtilTest {
|
||||
@Test
|
||||
public void briefTest() {
|
||||
// case: 1 至 str.length - 1
|
||||
final String str = RandomUtil.randomString(RandomUtil.randomInt(1, 100));
|
||||
final String str = RandomUtil.randomStringLower(RandomUtil.randomInt(1, 100));
|
||||
for (int maxLength = 1; maxLength < str.length(); maxLength++) {
|
||||
final String brief = StrUtil.brief(str, maxLength);
|
||||
Assertions.assertEquals(brief.length(), maxLength);
|
||||
|
@@ -47,9 +47,9 @@ public class TextSimilarityTest {
|
||||
@Disabled
|
||||
void longestCommonSubstringLengthTest() {
|
||||
// https://github.com/dromara/hutool/issues/3045
|
||||
final String strCommon = RandomUtil.randomString(1024 * 32);
|
||||
final String strA = RandomUtil.randomString(1024 * 32) + strCommon;
|
||||
final String strB = RandomUtil.randomString(1024 * 32) + strCommon;
|
||||
final String strCommon = RandomUtil.randomStringLower(1024 * 32);
|
||||
final String strA = RandomUtil.randomStringLower(1024 * 32) + strCommon;
|
||||
final String strB = RandomUtil.randomStringLower(1024 * 32) + strCommon;
|
||||
|
||||
final int i = TextSimilarity.longestCommonSubstringLength(strA, strB);
|
||||
Console.log(i);
|
||||
|
@@ -16,7 +16,6 @@ import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.math.NumberUtil;
|
||||
import org.dromara.hutool.core.util.RandomUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -90,7 +89,7 @@ public class RandomUtilTest {
|
||||
|
||||
@Test
|
||||
public void randomStringOfLengthTest(){
|
||||
final String s = RandomUtil.randomString("123", -1);
|
||||
final String s = RandomUtil.randomStringLower("123", -1);
|
||||
Assertions.assertNotNull(s);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user