!503 fix: 对RandomUtil.randomStringWithoutStr排除字符串兼容大写字母

Merge pull request !503 from dream/v5-dev
This commit is contained in:
Looly
2022-01-15 16:35:58 +00:00
committed by Gitee
2 changed files with 13 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ import org.junit.Test;
import java.math.RoundingMode;
import java.util.List;
import java.util.Locale;
import java.util.Set;
public class RandomUtilTest {
@@ -59,4 +60,14 @@ public class RandomUtilTest {
char c = RandomUtil.randomChinese();
Assert.assertTrue(c > 0);
}
@Test
public void randomStringWithoutStrTest() {
for (int i = 0; i < 100; i++) {
final String s = RandomUtil.randomStringWithoutStr(8, "0IPOL");
System.out.println(s);
for (char c : "0IPOL".toCharArray()) {
Assert.assertFalse(s.contains((String.valueOf(c).toLowerCase(Locale.ROOT))));
}
}
}
}