fix StrUtil.split切分长度为0时的bug;

This commit is contained in:
Zjp 2023-02-17 10:50:31 +08:00
parent 27b1ff8330
commit 6cd85b7f16
2 changed files with 4 additions and 0 deletions

View File

@ -19,6 +19,7 @@ public class LengthFinder extends TextFinder {
* @param length 长度
*/
public LengthFinder(int length) {
Assert.isTrue(length > 0, "Length must be great than 0");
this.length = length;
}

View File

@ -70,6 +70,9 @@ public class StrUtilTest {
final String[] strings = StrUtil.splitToArray("abc/", '/');
Assert.assertEquals(2, strings.length);
// issue:I6FKSI
Assert.assertThrows(IllegalArgumentException.class, () -> StrUtil.split("test length 0", 0));
}
@Test