断言增加支持自定义异常

This commit is contained in:
lixiaohua
2020-08-10 17:32:12 +08:00
parent 18523dd60f
commit ae26f64a84
2 changed files with 32 additions and 0 deletions

View File

@@ -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);
}
}