This commit is contained in:
Looly 2021-03-12 20:37:55 +08:00
parent b184ad79da
commit 50d0569e8c
2 changed files with 3 additions and 2 deletions

View File

@ -1294,8 +1294,8 @@ public class NumberUtil {
end = temp;
}
// 加入逻辑判断确保begin<end并且size不能大于该表示范围
Assert.isTrue((end - begin) > size, "Size is larger than range between begin and end!");
Assert.isTrue(seed.length > size, "Size is larger than seed size!");
Assert.isTrue((end - begin) >= size, "Size is larger than range between begin and end!");
Assert.isTrue(seed.length >= size, "Size is larger than seed size!");
final int[] ranArr = new int[size];
// 数量你可以自己定义

View File

@ -361,6 +361,7 @@ public class NumberUtilTest {
@Test
public void generateRandomNumberTest2(){
// 检查边界
final int[] ints = NumberUtil.generateRandomNumber(1, 8, 7);
Assert.assertEquals(7, ints.length);
final Set<?> set = Convert.convert(Set.class, ints);