!944 修复StrUtil.split切分长度为0时的bug

Merge pull request !944 from emptypoint/fix-StrUtil.split
This commit is contained in:
Looly 2023-02-20 07:44:34 +00:00 committed by Gitee
commit f4cfc5d5ed
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
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