mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -1,15 +1,13 @@
|
|||||||
package cn.hutool.core.lang;
|
package cn.hutool.core.lang;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.func.Func0;
|
import cn.hutool.core.lang.func.Func0;
|
||||||
import cn.hutool.core.lang.func.VoidFunc0;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 断言<br>
|
* 断言<br>
|
||||||
* 断言某些对象或值是否符合规定,否则抛出异常。经常用于做变量检查
|
* 断言某些对象或值是否符合规定,否则抛出异常。经常用于做变量检查
|
||||||
@@ -26,6 +24,7 @@ public class Assert {
|
|||||||
* Assert.isTrue(i > 0, IllegalArgumentException::new);
|
* Assert.isTrue(i > 0, IllegalArgumentException::new);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
* @param <X> 异常类型
|
||||||
* @param expression 布尔值
|
* @param expression 布尔值
|
||||||
* @param supplier 指定断言不通过时抛出的异常
|
* @param supplier 指定断言不通过时抛出的异常
|
||||||
* @throws X if expression is {@code false}
|
* @throws X if expression is {@code false}
|
||||||
|
@@ -21,7 +21,7 @@ public class AssertTest {
|
|||||||
cn.hutool.core.lang.Assert.isTrue(i > 0, IllegalArgumentException::new);
|
cn.hutool.core.lang.Assert.isTrue(i > 0, IllegalArgumentException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IndexOutOfBoundsException.class)
|
@Test()
|
||||||
public void isTrueTest2() {
|
public void isTrueTest2() {
|
||||||
int i = -1;
|
int i = -1;
|
||||||
cn.hutool.core.lang.Assert.isTrue(i >= 0, IndexOutOfBoundsException::new);
|
cn.hutool.core.lang.Assert.isTrue(i >= 0, IndexOutOfBoundsException::new);
|
||||||
|
Reference in New Issue
Block a user