mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
断言增加支持自定义异常
This commit is contained in:
@@ -14,4 +14,16 @@ public class AssertTest {
|
||||
String a = null;
|
||||
cn.hutool.core.lang.Assert.isNull(a);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void isTrueTest() {
|
||||
int i = 0;
|
||||
cn.hutool.core.lang.Assert.isTrue(i > 0, IllegalArgumentException::new);
|
||||
}
|
||||
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void isTrueTest2() {
|
||||
int i = -1;
|
||||
cn.hutool.core.lang.Assert.isTrue(i >= 0, IndexOutOfBoundsException::new);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user