mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Assert新增断言给定集合为空的方法以及单元测试用例
This commit is contained in:
@@ -4,6 +4,9 @@ import cn.hutool.core.util.StrUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AssertTest {
|
||||
|
||||
@Test
|
||||
@@ -68,4 +71,13 @@ public class AssertTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyCollectionTest() {
|
||||
List<Object> testList = new ArrayList<>();
|
||||
Assertions.assertDoesNotThrow(() -> Assert.empty(null));
|
||||
Assertions.assertDoesNotThrow(() -> Assert.empty(testList));
|
||||
testList.add(new Object());
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Assert.empty(testList));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user